Skip to content

Studio: no text selection from the clicks that follow a dropdown dismissal - #16077

Merged
shimmyshimmer merged 6 commits into
mainfrom
studio-dropdown-dismiss-select
Oct 30, 2026
Merged

shimmyshimmer merged 6 commits into
mainfrom
studio-dropdown-dismiss-select

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

What changed

Closing a dropdown by clicking elsewhere no longer leaves text highlighted. Before, a quick second click selected a word, and a third selected a whole message or, in Settings, the entire dialog. This affected every dropdown, select and popover, on every page.

Why

The OS counts the press that closes a menu as click 1 of a click sequence. The menu swallows that press, so people click again, and the next quick clicks arrive with click count 2 and 3. The browser treats those as a double click (select word) and a triple click (select block).

A capture-phase guard, installed once in AppProvider (src/lib/dismiss-click-streak.ts), notes when a left press lands outside an open Radix menu, listbox or popover. For the rest of that click sequence, each press selects as if the dismissing click had not counted:

  • click 2 places the caret
  • click 3 selects the word (Intl.Segmenter, since Selection.modify word steps differ by platform)
  • click 4 and later select the enclosing block

The press that closes the menu is untouched, and so are text fields. Double and triple clicks select as usual when no menu was just closed, and a fast run of clicks still ends up selecting text.

Verification

  • npm run typecheck, npm run build: clean.

  • npm test: 14,463 of 14,468 pass, 1 skipped. The 4 failures are in hub-gguf-card-unified-budget.test.ts and fail identically on main.

  • New tests/dismiss-click-streak.test.ts:

    • follow-ups after a dismissal select one step finer
    • the click-count to granularity mapping
    • word bounds from Intl.Segmenter
    • normal double and triple clicks still select
    • a new click sequence resets the guard
    • presses inside the menu and in text fields keep native selection
    • the guard installs once and removes its listeners
  • Playwright, WebKit and Chromium. Each case opens a menu, then sends a hand-paced click sequence (click count 1, 2, 3, about 180ms apart) onto nearby text:

    Menu Before (click 2 / click 3) After (click 2 / click 3)
    Settings Theme "Accent" / "Accent " nothing / "Accent"
    Settings UI font "Contrast" / "Contrast " nothing / "Contrast"
    Composer "Approve for me" "Lorem" / whole 347-char message nothing / "Lorem"
    Account menu "Lorem" / whole 347-char message nothing / "Lorem"
    • A fast run of 8 clicks after a dismissal selects the caret, the word, then the block, instead of nothing.
    • At 12 points across four words, the word and block selected after a dismissal match a native double and triple click in 47 of 48 cases. The exception is Chromium on the last 2px of a word's final letter, where native selects the following space.

Also in this PR

Comment-only trims to thread.tsx, images-page.tsx and video-page.tsx, carried over from #16076 and #16081, which merged before their final comment pass.

Not covered

Not tested in the Desktop app's native WebView or on touch input. The guard only acts on mouse click counts above 1.

…issal

The OS counts the press that closes a menu as click 1, so the next quick clicks
arrive as a double and triple click and select a word, then a whole block. A
capture guard in AppProvider prevents the mousedown default for the rest of a
click run that started by dismissing a Radix menu, listbox or popover.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T08:32:44.169620Z f0636f0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 738dd7dde4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Blocking every press in the dismissing click run left text unselectable while
clicks kept coming quickly. Each later press now selects as if the dismissing
click had not counted: caret, then word, then paragraph.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be6a65effc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +126 to +128
} else if (streakFromDismiss && !target?.closest(TEXT_ENTRY)) {
event.preventDefault();
select(event, target);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve drag selection after dismissing a menu

If a user dismisses a menu over message text and immediately presses again and drags to select text, the second press has detail === 2 and enters this branch. Canceling mousedown prevents the browser from starting its native drag-selection gesture, while select() only sets a collapsed caret at the initial coordinates; there is no mouse-move handling to extend it. Consequently, users cannot select an arbitrary text range with that gesture until they pause long enough to reset the click count. Preserve drag selection while adjusting the initial selection granularity.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in f0636f0: the shifted press now follows the drag and extends the selection by its unit (caret, word or block), matching a native drag in WebKit.

Cancelling that press also cancelled its native drag selection. The guard now
follows the drag and extends the selection by the press's unit, as a native
drag does.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0636f026b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +175 to +178
const onMouseMove = (event: MouseEvent): void => {
if (!extend) return;
if (event.buttons & 1) extend(event.clientX, event.clientY);
else extend = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve edge autoscrolling during shifted drag selection

When a user dismisses a menu and immediately drags to select a message longer than the chat viewport, canceling mousedown disables the browser's native selection gesture, including edge autoscrolling. The replacement only updates selection coordinates on mousemove; it never scrolls the container or continues updating while the pointer is stationary at its edge. Consequently, this gesture cannot select text beyond the visible portion of the scrollable chat viewport. Add edge autoscrolling to the replacement drag behavior or preserve the native drag gesture.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not changing this: it needs a drag started within the double-click interval of a menu dismissal that also runs past the viewport edge. Any drag after that interval is native, autoscroll included, and a custom autoscroller for that window is more risk than the case warrants.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: f0636f026b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen added a commit that referenced this pull request Oct 30, 2026
…#16082)

`Frontend unit tests` is red on main. All four cases in
`studio/frontend/tests/hub-gguf-card-unified-budget.test.ts` fail (seen
on #16077's run):

```
not ok - the Hub GGUF card recommends a quant inside the Mac's Metal load budget
  error: 'no stub for import "@/lib/folder-icons" in .../src/features/hub/catalog/gguf-download-card.tsx'
```

#15958 moved the card's folder glyph to `@/lib/folder-icons` and added
that stub to the other `loadWithStubs` tests. This test, from #15848 and
merged the same day, was not in that sweep. The card is correct; the
test's stub map was one module behind. This adds `"@/lib/folder-icons":
anyExport` next to the other icon stubs.

## Verification

- `node --test tests/hub-gguf-card-unified-budget.test.ts`: 4 failed on
main, 4 passed here.
- The full frontend suite on main fails only these four.
@shimmyshimmer
shimmyshimmer merged commit e07e636 into main Oct 30, 2026
3 of 42 checks passed
@shimmyshimmer
shimmyshimmer deleted the studio-dropdown-dismiss-select branch October 30, 2026 08:42
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.

1 participant