fix: open the context popup when a pointer selection is released outside the editor - #190
Merged
Merged
Conversation
ProseMirror registers `handleDOMEvents` on `view.dom` and tracks its own drags from `view.root`, so a release over the navigator, over other chrome, or outside the window ended the drag without opening the popup. The latch on `mousedown` keeps the root listener to gestures the editor started.
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.
Summary
view.rootlistener owned by the plugin's view, rather than from amouseupentry inhandleDOMEvents. ProseMirror registershandleDOMEventsonview.domalone while tracking its own drags from the root, so a release over the article navigator, over other application chrome, or outside the window ended the drag with the selection correct and the popup unopened.mousedownhandler'spointerSelectingflag, so the root listener answers only for gestures the editor started. Without it, any release anywhere in the application would open the popup while the editor holds a selection.destroy.event.button !== 0guard, the collapsed-selection close, the deferral to the next frame, and the keyboard and right-click open paths are unchanged.Related Issue
Closes #168
Verification
Focused tests in
contextPopup.test.tsxcover a release on the document after amousedownin the editor, a gesture that both begins and ends outside the editor while a dismissed selection stands, and a release arriving after the editor is destroyed. The first fails onmain; the second fails against a root listener without the latch.Two existing tests dispatched a bare
mouseuponview.domand now dispatch themousedownfirst: under the latch a release without a matching press is no longer a gesture the editor can produce. That is the one oracle change here, and it encodes the issue's third acceptance criterion rather than accommodating the implementation.docs/specification.mdgains the release-location clause and the begins-outside rule on the line that already promised the fixed behavior.Manually verified in the development build on Windows 11:
mouseupthat ends a drag started in the page.