Skip to content

Commit

Permalink
FIx: Handle values
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto committed Dec 17, 2023
1 parent 1f04dae commit 303e379
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
18 changes: 11 additions & 7 deletions Resources/Private/RangeEditor/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function Editor(props, second) {
const styleWidth = Math.max(numLength(options.min), numLength(options.max)) + additionalStepLength + "ch";

const { valueLabels, valueLabelsFile } = options;
const showMiddle = !!(value != options.min && value != options.max);
const showMiddle = between(value, options.min, options.max);
const getValueLabel = (value) => {
if (valueLabels && valueLabels[value]) {
return valueLabels[value];
Expand All @@ -69,11 +69,11 @@ function Editor(props, second) {
};

const getLabel = (value) => {
if (value == options.min) {
if (value <= options.min) {
const label = options.minLabel || getValueLabel(options.min) || options.min + options.unit;
return i18nRegistry.translate(label);
}
if (value == options.max) {
if (value >= options.max) {
const label = options.maxLabel || getValueLabel(options.max) || options.max + options.unit;
return i18nRegistry.translate(label);
}
Expand All @@ -99,7 +99,7 @@ function Editor(props, second) {
type="button"
title={i18nRegistry.translate("Neos.Neos.Ui:Main:rangeEditorMinimum")}
onClick={() => changeValue(options.min)}
style={{ opacity: options.min == value ? 1 : 0.7 }}
style={{ opacity: options.min >= value ? 1 : 0.7 }}
disabled={options.disabled}
>
{getLabel(options.min)}
Expand All @@ -111,8 +111,8 @@ function Editor(props, second) {
<input
title={i18nRegistry.translate("Neos.Neos.Ui:Main:rangeEditorCurrentValue")}
type="text"
onKeyPress={this.onKeyPress}
onChange={this.handleChange}
onKeyPress={onKeyPress}
onChange={handleChange}
value={valueAsString}
style={{ width: styleWidth }}
disabled={options.disabled}
Expand All @@ -124,7 +124,7 @@ function Editor(props, second) {
type="button"
title={i18nRegistry.translate("Neos.Neos.Ui:Main:rangeEditorMaximum")}
onClick={() => changeValue(options.max)}
style={{ opacity: options.max == value ? 1 : 0.7 }}
style={{ opacity: options.max <= value ? 1 : 0.7 }}
disabled={options.disabled}
>
{getLabel(options.max)}
Expand All @@ -142,4 +142,8 @@ function useForceUpdate() {
// is better than directly setting `setValue(value + 1)`
}

function between(x, min, max) {
return x > min && x < max;
}

export default neosifier(Editor);
2 changes: 1 addition & 1 deletion Resources/Public/Plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 303e379

Please sign in to comment.