Skip to content

Conversation

@frmalinowski
Copy link
Contributor

DateInput onClose callback is not called with last picked date when value property is present

DateInput onClose callback is not called with last picked date when value property is present
@github-actions
Copy link
Contributor

Released prerelease version 7.9.1-dateinput-onclose-fix-b705bd8.0.
You may now run npm install @appfolio/react-gears@dateinput-onclose-fix

this.setInputValue();
if (this.props.onClose && this.state.open !== prevState.open && !this.state.open) {
const value = this.props.value !== undefined ? this.props.value : this.state.value;
const value = this.state.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

this.state.value can be an empty string even if props.value is provided. Try it by opening the calendar and closing it without selecting a date and providing props.value.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can fix the issue I mentioned above by changing this line in the contructor:

- let value = props.defaultValue || '';
+ let value = props.value || props.defaultValue || '';

@steventhan steventhan force-pushed the master branch 5 times, most recently from fc7b9c2 to 440bf24 Compare April 7, 2023 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants