fix(DismissibleLayer): make #resetState synchronous - #2111
Open
MathiasWP wants to merge 1 commit into
Open
Conversation
The 20ms debounce on #resetState is vestigial: it dates from when the reset was also wired to a capture-phase interaction-end listener and had to land after the 10ms #handleInteractOutside debounce. huntabyte#785 removed that listener but left the timing on the cleanup() path. Because watch([enabled, ref]) runs cleanup() once on every open (ref goes null -> node), every layer scheduled a reset 20ms into its own lifetime. An outside pointerdown landing 10-20ms after that cleanup had its #isResponsibleLayer flag cleared by the stale reset in the gap before the debounced #handleInteractOutside ran, so the handler bailed and the layer stayed open. This is the 'should close on outside click' CI flake. Adds a delay-sweep regression test that clicks outside at a range of offsets after the layer registers; it fails 4-5 of 20 without the fix and passes 20/20 with it.
🦋 Changeset detectedLatest commit: eb47caf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
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.
Fixes the intermittent
should close on outside clickfailures in combobox/select/menubar.Problem
#resetStateclears#isResponsibleLayerbehind adebounce(..., 20), and is only called fromcleanup(). Sincewatch([enabled, ref])runscleanup()once on every open (ref.currentgoesnull -> node), every layer schedules a state wipe 20ms into its own lifetime, ~1.5ms before it attaches its listeners.An outside
pointerdownschedules#handleInteractOutsideon a 10ms debounce, so a click landing 10-20ms after that cleanup gets the stale reset in between:The debounce is vestigial: #785 removed the capture-phase interaction-end listener it was wired to (where landing after the 10ms handler debounce was the point) but left the timing on the
cleanup()path.Fix
Make
#resetStatesynchronous.cleanup()destroys#handleInteractOutsidein the same breath, so nothing in flight needs the pre-reset state.Test
tests/src/tests/dismissible-layer/outside-click-timing.browser.test.tssweeps the outside-click delay after layer registration. Fails 4-5 of 20 without the fix, passes 20/20 with it.Other verification, chromium
--retry=0: