Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Fix number inputs for IE11 #730

Merged
merged 9 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added responsiveness on graph parent element resize (previously only worked on window.resize)
- Added new `dash-graph--pending` class to dcc.Graph, present while resizing, (re-)rendering, loading

### Fixed
- [#731](https://github.com/plotly/dash-core-components/pull/731) Fixed bug in which input components with type `number` did not correctly update their values.

### Changed
- [#723](https://github.com/plotly/dash-core-components/pull/723) Changed npm package content to allow source code inclusion from other projects
- [#725](https://github.com/plotly/dash-core-components/pull/725) Improve async graph performance by parallelizing resource fetching instead of fetching sequentially
Expand Down
14 changes: 11 additions & 3 deletions src/components/Input.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export default class Input extends PureComponent {
this.onKeyPress = this.onKeyPress.bind(this);
this.setInputValue = this.setInputValue.bind(this);
this.setPropValue = this.setPropValue.bind(this);
this.getValueAsNumber = this.getValueAsNumber.bind(this);
}

componentWillReceiveProps(nextProps) {
const {value, valueAsNumber} = this.input.current;
const {value} = this.input.current;
const valueAsNumber = this.getValueAsNumber(value);
this.setInputValue(
isNil(valueAsNumber) ? value : valueAsNumber,
nextProps.value
Expand All @@ -42,7 +44,8 @@ export default class Input extends PureComponent {
}

componentDidMount() {
const {value, valueAsNumber} = this.input.current;
const {value} = this.input.current;
const valueAsNumber = this.getValueAsNumber(value);
this.setInputValue(
isNil(valueAsNumber) ? value : valueAsNumber,
this.props.value
Expand Down Expand Up @@ -89,6 +92,10 @@ export default class Input extends PureComponent {
);
}

getValueAsNumber(value) {
return convert(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point why not just call convert directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 21281de!

}

setInputValue(base, value) {
const __value = value;
base = this.input.current.checkValidity() ? convert(base) : NaN;
Expand All @@ -109,7 +116,8 @@ export default class Input extends PureComponent {
}

onEvent() {
const {value, valueAsNumber} = this.input.current;
const {value} = this.input.current;
const valueAsNumber = this.getValueAsNumber(value);
if (this.props.type === 'number') {
this.setPropValue(
this.props.value,
Expand Down