Skip to content

fix(mosaic): keep menu items from showing focus rings on mouse hover - #9986

Merged
alexcarpenter merged 1 commit into
mainfrom
carp/mosaic-focus-visible
Sep 29, 2026
Merged

alexcarpenter merged 1 commit into
mainfrom
carp/mosaic-focus-visible

Conversation

@alexcarpenter

Copy link
Copy Markdown
Member

Description

Menus opened with the mouse showed keyboard focus rings on items as they were hovered.

The menu opened on mousedown through floating-ui's useClick, which calls preventDefault() on that mousedown so the trigger never receives focus from the press. With no mouse focus recorded, the browser treats the focus the menu then moves by script (to the popup, and to each hovered item) as keyboard-driven, so every item matched :focus-visible.

The menu still opens on press, but now handles a mouse or pen pointerdown on the trigger itself without preventing the default, so the trigger takes focus from the press and the focus that follows inherits "not visible". useClick keeps handling keyboard and touch. Arrow-key navigation still shows the ring. This matches how Base UI opens its menus.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Sep 29, 2026 8:08pm UTC
swingset Ready Ready Preview Sep 29, 2026 8:08pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 69dd987

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

This PR includes changesets to release 2 packages
Name Type
@clerk/mosaic Patch
@clerk/swingset 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

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Team

Run ID: a1cc0b24-1aec-4d72-ad71-55111620cc76

📥 Commits

Reviewing files that changed from the base of the PR and between e34a5cc and 69dd987.

📒 Files selected for processing (3)
  • .changeset/mosaic-menu-pointer-focus-ring.md
  • packages/mosaic/src/primitives/menu/menu-root.tsx
  • packages/mosaic/src/primitives/menu/menu.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 7 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.


📝 Walkthrough

Walkthrough

MenuInner now configures useClick to ignore mouse input and adds a pointer-down handler for non-nested menus. The handler toggles the menu for left-button mouse and pen events. A test checks that a mouse press opens the menu and focuses the trigger. A patch changeset records a note about menu-item focus rings.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: ⚪ Minimal · up to 69dd9

No actionable user-facing regression is established by the reviewed change; the test coverage gap does not by itself demonstrate incorrect menu behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main fix: preventing focus rings on Mosaic menu items during mouse hover.
Description check ✅ Passed The description explains the focus behavior, the Floating UI interaction change, the expected keyboard and pointer behavior, and the related tests and build checks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9986

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9986

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9986

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9986

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9986

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9986

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9986

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9986

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9986

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9986

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9986

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9986

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9986

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9986

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@9986

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9986

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9986

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9986

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9986

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9986

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9986

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9986

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9986

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9986

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9986

commit: 69dd987

@alexcarpenter
alexcarpenter merged commit dae1592 into main Sep 29, 2026
85 of 86 checks passed
@alexcarpenter
alexcarpenter deleted the carp/mosaic-focus-visible branch September 29, 2026 22:27

This branch was successfully deployed

2 active deployments
Preview – swingset — 69dd9879 Deployed Sep 29, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 69dd9879 Deployed Sep 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants