Skip to content

Commit ec2a2b5

Browse files
committed
BUGFIX: Allow float numbers as steps in RangeEditor
1 parent 3b89b9a commit ec2a2b5

File tree

1 file changed

+5
-2
lines changed
  • packages/neos-ui-editors/src/Editors/Range

1 file changed

+5
-2
lines changed

packages/neos-ui-editors/src/Editors/Range/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class RangeEditor extends PureComponent {
4242
const {options} = this.props;
4343
const {target} = event;
4444

45-
let value = parseInt(target.value, 10);
45+
let value = parseFloat(target.value, 10);
4646
if (isNaN(value)) {
4747
return;
4848
}
@@ -64,7 +64,10 @@ class RangeEditor extends PureComponent {
6464
const options = {...this.constructor.defaultProps.options, ...this.props.options};
6565
const {value, highlight} = this.props;
6666
const valueAsString = value === 0 ? '0' : (value || '');
67-
const styleWidth = Math.max(options.min.toString().length, options.max.toString().length) + 'ch';
67+
// Calculate the width of the input field based on the length of the min, max and step values
68+
const numLength = (value) => value.toString().length;
69+
const additionalStepLength = numLength(options.step) - 1;
70+
const styleWidth = Math.max(numLength(options.min), numLength(options.max)) + additionalStepLength + 'ch';
6871

6972
return (
7073
<div

0 commit comments

Comments
 (0)