Skip to content

fix: preserve editor focus when opening dropdowns - #507

Merged
alexwarren merged 1 commit into
mainfrom
codex/zamb-225-editor-dropdown-focus
Aug 6, 2026
Merged

fix: preserve editor focus when opening dropdowns#507
alexwarren merged 1 commit into
mainfrom
codex/zamb-225-editor-dropdown-focus

Conversation

@alexwarren

@alexwarren alexwarren commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • cancel mousedown within the built-in editor menu container so mouse activation does not blur the editor
  • keep plugin controls outside the menu focusable
  • add unit and browser regression coverage, with the test dependency updated to Stacks 2.9.0
  • add a patch changeset

Context

This fixes the underlying Stacks Editor focus-handling gap exposed by Stacks 2.9.0. When a mouse opened an editor dropdown, the editor click handler restored focus to the editor; Stacks then treated that focus move as leaving the trigger/popover pair and immediately dismissed the menu.

Stacks Editor already documents this focus-preservation behavior in two places: setupPluginContainer() says toolbar mouse interactions are cancelled to prevent the editor from blurring, and MenuView says the standard StacksEditor setup handles this automatically. However, the built-in setup never installed the documented mousedown handler. This change closes that existing implementation gap; Stacks 2.9's focus-leave behavior merely made the gap observable.

This is the upstream fix for the temporary Stack Overflow workarounds in StackEng/StackOverflow#26004 and StackEng/StackOverflow#26010.

Testing

  • npm run lint
  • npm run test:unit -- --runInBand — 48 suites, 1,092 tests passed
  • npm run test:e2e — 195 tests passed across Chromium, Firefox, and WebKit
  • npm run build
  • git diff --check

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f1f342e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stackoverflow/stacks-editor Patch

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

@netlify

netlify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploy Preview for stacks-editor ready!

Name Link
🔨 Latest commit f1f342e
🔍 Latest deploy log https://app.netlify.com/projects/stacks-editor/deploys/6a73445542ab1a0008a0be48
😎 Deploy Preview https://deploy-preview-507--stacks-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@alexwarren
alexwarren marked this pull request as ready for review August 5, 2026 14:16
@alexwarren alexwarren changed the title [ZAMB-225] Preserve editor focus when opening dropdowns fix: preserve editor focus when opening dropdowns Aug 5, 2026
@asblanco
asblanco requested a review from dancormier August 5, 2026 15:03

@dancormier dancormier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really solid change @alexwarren. I looked through the code plus tested manually and it all seems good. Thanks!

@alexwarren
alexwarren merged commit 0807e9d into main Aug 6, 2026
12 of 13 checks passed
@alexwarren
alexwarren deleted the codex/zamb-225-editor-dropdown-focus branch August 6, 2026 09:15
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.

2 participants