Repository navigation
Conversation
Picking a day sets state.value and closes the picker in the same update, before the parent re-renders with the new value prop. onClose read the value prop whenever it was defined, so controlled callers always got the pre-selection value. Prefer state.value when it changed in the closing update; otherwise keep using the value prop so external changes still win. Also stop spreading onClose onto the <input> as an unknown DOM prop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Released prerelease version |
Contributor
Author
|
One decision needed that impacts user experience:
Screen.Recording.2026-10-20.at.11.07.02.AM.movSteps: Expect From to stay empty on 1, and the old date to come back on 2. |
mike-mike-mike-mike-mike
approved these changes
Oct 26, 2026
mike-mike-mike-mike-mike
left a comment
Contributor
There was a problem hiding this comment.
Let's try to get this merged!
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
With a controlled
valueprop,DateInput'sonClosenever sees a date picked from the calendar. It always gets the value from before the pick.Picking a day calls
setDate, which setsstate.valueandopen: falsein onesetState.componentDidUpdatesees the close and firesonCloseright away, but it readsthis.props.valuewhenever that's defined. The parent hasn't re-rendered with the new value yet (onChangeruns in thesetStatecallback, aftercomponentDidUpdate), soonClosegets the old one.Uncontrolled callers aren't affected because they already read
state.value.The fix
componentDidUpdate, usestate.valueforonClosewhen it's uncontrolled or whenstate.valuechanged in the update that closed the picker (a pick or Today). Otherwise keep using thevalueprop. That way, if the parent changesvalueon its own (a "clear filters" reset, say) and the user then opens and closes the picker without picking,onClosestill reports the parent's value and not an old pick left in state.onCloseto the props pulled out inrenderso it isn't spread onto the<input>as an unknown DOM prop.Tests
New
onClosespecs inDateInput.spec.js:onClosegets the picked date (failed before the fix)onClosegets the picked date (regression guard)value, open then Esc →onClosegets the new prop value (guards the case above)onCloseisn't passed to the<input>(failed before the fix)yarn lint,yarn formatandyarn testpass locally.Why now
This came up in https://github.com/appfolio/apm_bundle/pull/126484 (owners Advanced Filters date inputs). The filter needed to act when the picker closed, but
onClosewith a controlledvaluealways got the old date, so that PR had to avoidonCloseentirely. The only otheronClosecallers in apm_bundle work only because they're uncontrolled.🤖 Generated with Claude Code
[GROWN-45]