fix(TextSelectionLayer): avoid reading destroyed ref box on document pointerdown - #2107
Merged
huntabyte merged 1 commit intoAug 19, 2026
Conversation
…pointerdown #pointerdown read this.opts.ref.current as its first statement, before the enabled check. When the document listener outlives its component, that box is a $derived owned by a destroyed effect, so every pointerdown anywhere in the document re-executed it and emitted derived_inert, permanently. Check the plain-boolean #enabledSnapshot first. Same logical condition, but a leaked listener no longer touches the destroyed derived.
🦋 Changeset detectedLatest commit: 9442b98 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
|
Contributor
Author
|
CI red here is #2102's race, not this change — both failures are Local A/B on Should go green once #2102 lands; happy to rebase onto it instead if preferred. |
Merged
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.
TextSelectionLayerState.#pointerdownreadthis.opts.ref.currentas its first statement, before the enabled check.That box is a
$derivedowned by the Content component. When the documentpointerdownlistener outlives its component (reproducible by rapidly toggling a Dialog/Popover open/closed), every pointerdown anywhere in the document re-executes a destroyed derived and emitsderived_inert— permanently, for any click target.Fix: check the plain-boolean
#enabledSnapshotfirst. Same logical condition; a leaked listener no longer touches the destroyed derived.Notes
DismissibleLayer). HerebitsTextSelectionLayersis correctly emptied — only the listener leaks — so fix: cancel DismissibleLayer afterSleep timer on destroy (#2080) #2087 does not cover it.DismissibleLayercase emits 6 (3 + 3, split by the 10ms debounce).derived_inert#2050, derived_inert warning in useFloating: race between autoUpdate rAF and Svelte 5 effect teardown #2083, LinkPreview: pointerup's afterSleep(1) timer isn't cancelled on close, same shape as #2080 #2103, Select: scrollIntoViewTimer (afterSleep) never cancelled on destroy, same shape as #2080/#2103 #2106.removeEventListenerleak is still unresolved and worth a separate issue; this guard makes it harmless.Related: #2080, #2105