Skip to content

fix: open the context popup when a pointer selection is released outside the editor - #190

Merged
Azganoth merged 1 commit into
mainfrom
bug/context-popup-pointer-release-outside-editor
Aug 10, 2026
Merged

fix: open the context popup when a pointer selection is released outside the editor#190
Azganoth merged 1 commit into
mainfrom
bug/context-popup-pointer-release-outside-editor

Conversation

@Azganoth

@Azganoth Azganoth commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Complete a pointer selection from a view.root listener owned by the plugin's view, rather than from a mouseup entry in handleDOMEvents. ProseMirror registers handleDOMEvents on view.dom alone 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.
  • Latch the gesture on the existing mousedown handler's pointerSelecting flag, 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.
  • Dispose the listener in the plugin view's destroy.
  • The event.button !== 0 guard, 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.tsx cover a release on the document after a mousedown in 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 on main; the second fails against a root listener without the latch.

Two existing tests dispatched a bare mouseup on view.dom and now dispatch the mousedown first: 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.md gains 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:

  1. A selection dragged from the editor and released over the article navigator opens the popup, anchored to the selection.
  2. The same release over the title bar opens it.
  3. The same release outside the application window opens it, so WebView2 does deliver the mouseup that ends a drag started in the page.
  4. Clicking a navigator row while the editor holds a dismissed selection leaves the popup closed.

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.
@Azganoth
Azganoth enabled auto-merge (squash) August 10, 2026 06:52
@Azganoth Azganoth self-assigned this Aug 10, 2026
@Azganoth Azganoth added the Bug Something isn't working label Aug 10, 2026
@Azganoth
Azganoth merged commit 5ec6a55 into main Aug 10, 2026
3 checks passed
@Azganoth
Azganoth deleted the bug/context-popup-pointer-release-outside-editor branch August 10, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pointer selection released outside the editor does not open the context popup

1 participant