Conversation
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.
Description
Linked issue: #6328
Problem
resetInputValuewrites a full snapshot ofthis.stateback throughsetState:handleBlurcalls it. When the user clicks away from an open calendar, two things happen in one task:mousedownlistener inClickOutsideWrapperrunshandleCalendarClickOutside, which callssetOpen(false).handleBlurruns.That listener is a plain
addEventListener, so React has not committed theopen: falseupdate by the time step 2 runs.this.statestill holdsopen: true, and the snapshot spread writes it back. The calendar closes and immediately reopens, then sits over whatever is below it.Changes
Set only the field the method is named for:
Added
src/test/reset_input_value.test.tsx, which fails onmainwithExpected length: 0, Received length: 1and passes with this change.To reviewers
The spread was introduced in 58f4afc (released in 8.5.0). No other state field is meant to change here, so dropping the spread restores the intent of that commit while keeping its behaviour:
inputValueis still reset on blur when the popup is closed.The test dispatches the outside
mousedownand the inputfocusoutinside a singleact(). That ordering matters —userEvent.clickawaits between pointer events, which lets React commitopen: falsebefore the blur handler readsthis.state, and the bug does not appear.Contribution checklist