Skip to content

Commit

Permalink
Fix resetting to blank value
Browse files Browse the repository at this point in the history
When you change the `value` prop to a blank string,
Datetime.getSelectedDate() tries to parse the value using the format
string.  This fails for blank values, and then getSelectedDate() falls
back to the previously entered input value from this.state.inputValue,
ignoring the new `value` prop and making the reset fail.

Closes arqex#760.
  • Loading branch information
mgedmin committed Aug 10, 2022
1 parent 8071a79 commit 5770eb0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/DateTime.js
Expand Up @@ -520,6 +520,7 @@ export default class Datetime extends React.Component {
}

getInputValue() {
if ( this.props.value === '' ) return '';
let selectedDate = this.getSelectedDate();
return selectedDate ? selectedDate.format( this.getFormat('datetime') ) : this.state.inputValue;
}
Expand Down

0 comments on commit 5770eb0

Please sign in to comment.