Skip to content

Commit

Permalink
fix(core): onChange -> onChangeSet on substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
soup-in-boots committed May 3, 2024
1 parent 343aa96 commit ced2492
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/components/mapper/integer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useDecorator, useLocalizer } from '@forml/hooks';
import { FormType } from '../../types';

const valueExceptions = ['', '-'];
const valueReplacements = { '0-': '-' };

/**
* @component Integer
Expand All @@ -26,8 +27,11 @@ export default function Integer(props) {
function onChange(e) {
let value = e.target.value;

if (valueExceptions.includes(value)) {
props.onChange(e, value);
if (value in valueReplacements) {
props.onChangeSet(e, valueReplacements[value]);
return;
} else if (valueExceptions.includes(value)) {
props.onChangeSet(e, value);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/mapper/number.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Number(props) {
let value = e.target.value;

if (valueExceptions.includes(value)) {
props.onChange(e, value);
props.onChangeSet(e, value);
return;
}

Expand Down

0 comments on commit ced2492

Please sign in to comment.