Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Allow float numbers in RangeEditor #3651

Merged
merged 4 commits into from
Nov 5, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/neos-ui-editors/src/Editors/Range/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class RangeEditor extends PureComponent {
handleChange = event => {
const {options} = this.props;
const {target} = event;
const useParseInt = options.step % 1 === 0;
jonnitto marked this conversation as resolved.
Show resolved Hide resolved

let value = parseInt(target.value, 10);
let value = useParseInt ? parseInt(target.value, 10) : parseFloat(target.value, 10);
if (isNaN(value)) {
return;
}
Expand All @@ -64,7 +65,10 @@ class RangeEditor extends PureComponent {
const options = {...this.constructor.defaultProps.options, ...this.props.options};
const {value, highlight} = this.props;
const valueAsString = value === 0 ? '0' : (value || '');
const styleWidth = Math.max(options.min.toString().length, options.max.toString().length) + 'ch';
// Calculate the width of the input field based on the length of the min, max and step values
const numLength = value => value.toString().length;
const additionalStepLength = numLength(options.step) - 1;
const styleWidth = Math.max(numLength(options.min), numLength(options.max)) + additionalStepLength + 'ch';

return (
<div
Expand Down
Loading