Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: dateInput onClose not called with last picked date #1109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

@@ -274,7 +274,7 @@ export default class DateInput extends React.Component {
componentDidUpdate(prevProps, prevState) {
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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants