Skip to content

Commit

Permalink
Fixed #1470 - Dynamic options breaks InputNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Aug 20, 2020
1 parent 9573e6f commit c810d53
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,12 @@ export class InputNumber extends Component {
this.renderTooltip();
}

if (prevProps.value !== this.props.value) {
const isOptionChanged = this.isOptionChanged(prevProps);
if (isOptionChanged) {
this.constructParser();
}

if (prevProps.value !== this.props.value || isOptionChanged) {
const newValue = this.validateValue(this.props.value);
this.updateInputValue(newValue);

Expand All @@ -817,6 +822,11 @@ export class InputNumber extends Component {
}
}

isOptionChanged(prevProps) {
const optionProps = ['locale', 'localeMatcher', 'mode', 'currency', 'currencyDisplay', 'useGrouping', 'minFractionDigits', 'maxFractionDigits', 'suffix', 'prefix'];
return optionProps.some((option) => prevProps[option] !== this.props[option]);
}

componentWillUnmount() {
if (this.tooltip) {
this.tooltip.destroy();
Expand Down

0 comments on commit c810d53

Please sign in to comment.