Skip to content

Hide the quick actions toolbar for right-click selections - #138

Merged
ponytojas merged 2 commits into
mainfrom
task/d12-quick-actions-toolbar-webkit
Nov 26, 2026
Merged

ponytojas merged 2 commits into
mainfrom
task/d12-quick-actions-toolbar-webkit

Conversation

@ponytojas

Copy link
Copy Markdown
Collaborator

Closes #102

WebKit selects the word under a right-click, and the quick actions toolbar then appeared for that selection, covering the next line near the top of a document. A selection made by a right-click (context menu) no longer shows the toolbar; extending it with the keyboard or mouse shows it again. Drag, double-click and keyboard selections are unchanged.

The workaround in web/e2e/wordcounter.spec.ts (collapseRightClickSelection) is removed, and a spec covers the new behaviour.

Tests: tsc --noEmit clean, fmt/lint (existing warnings only), make e2e BROWSER=all passes in Chrome and WebKit.

@Lorena-J Lorena-J left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix resolves the toolbar overlap after a right-click. I found two regressions in Chrome: Ask the assistant… no longer opens the instruction field from the context menu, and clearing the selection and then reselecting the same word leaves the toolbar hidden. Both cases work on the base branch. Could we scope the suppression to the selection associated with that right-click, allow explicit actions to show the toolbar, and add regression tests for both cases?

Comment thread web/src/QuickActions.tsx Outdated
const visible = !dragging && (view.hasFocus || within || !!job || !!pending)
const visible =
!dragging &&
!(!pending && !job && hideSelection === `${sel.from}-${sel.to}`) &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a word selected, right-click it and choose Ask the assistant…. The menu closes, but the instruction field never opens because the visibility check still hides the toolbar for that selection. Could we let an explicit request to open the instruction field override the right-click suppression?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: an explicit request to open the instruction field now overrides the right-click suppression, so Ask the assistant… opens it. Covered by the new test 'Ask the assistant… from the context menu opens the instruction field for a right-click selection'.

Comment thread web/src/Editor.tsx
// WebKit selects the word under a right-click, maybe just after this event.
const mark = () => {
const m = view.current?.state.selection.main
setMenuSel(m && !m.empty ? `${m.from}-${m.to}` : '')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-click a word, right-click it, dismiss the context menu, then clear the selection and double-click the same word again. The toolbar stays hidden because the new selection has the same offsets as the one saved here. Could we clear the suppression when the selection changes so it applies only to that right-click selection?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the suppression is cleared as soon as the selection changes, so it only applies to the selection that right-click made. Reselecting the same word shows the toolbar again. Covered by the new test 'selecting the right-clicked word again shows the quick actions toolbar' (it fails without the fix in Chrome; the spec passes in Chrome and WebKit).

@ponytojas
ponytojas merged commit b7bbaf0 into main Nov 26, 2026
4 checks passed
@ponytojas
ponytojas deleted the task/d12-quick-actions-toolbar-webkit branch November 26, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick actions toolbar covers the next line after a right-click in WebKit

2 participants