Skip to content

[popover] Remove stray focus guards around trigger when modal - #4350

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:codex/popover-modal-focus-guards
Mar 19, 2026
Merged

atomiks merged 3 commits into
mui:masterfrom
atomiks:codex/popover-modal-focus-guards

Conversation

@atomiks

@atomiks atomiks commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Summary

This change keeps trigger-side focus guards out of fully trapped modal popovers while preserving the existing tab handoff path when modal={true} is used without a close part.

Changes

  • Shared the effective focus-trapping state between PopoverPopup and PopoverTrigger.
  • Removed trigger-adjacent focus guards only when the popup is actually running modal focus management.
  • Added regression tests for both the trapped modal path and the no-close fallback path.

@atomiks atomiks added type: bug It doesn't behave as expected. component: popover Changes related to the popover component. labels Mar 16, 2026
@pkg-pr-new

pkg-pr-new Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4350
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4350
    

commit: 17425a2

@mui-bot

mui-bot commented Mar 16, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+147B(+0.03%) 🔺+61B(+0.04%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Mar 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 17425a2
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69bb61ed7d587200088d7bc0
😎 Deploy Preview https://deploy-preview-4350--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@atomiks
atomiks force-pushed the codex/popover-modal-focus-guards branch from 4b21b8c to 558cf97 Compare March 17, 2026 08:13
@atomiks

atomiks commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

Codex Review

Overview

This patch makes Popover use the same focus-management decision in both the popup and the trigger, so modal={true} only drops the trigger-side guards when focus is actually trapped. It also adds regression coverage for both the trapped modal path and the no-close fallback path.

Findings (None)

No blocking issues found in this patch.

Confidence: 4/5

High confidence based on a full pass over the branch diff, a second sweep for React/rendering correctness, accessibility and keyboard behavior, API/state consistency, maintainability, performance risk, and test coverage, plus targeted verification with pnpm test:jsdom PopoverRoot --no-watch, pnpm exec eslint ..., and pnpm exec tsc -b tsconfig.json --pretty false.

Notes

  • Latest changes since the earlier draft PR version:
  • The branch was rebased onto the latest master.
  • The follow-up simplify pass replaced the custom popup layout-effect sync with store.useSyncedValue('focusManagerModal', focusManagerModal) while preserving the detached-trigger behavior.

@atomiks atomiks changed the title [popover] Fix modal trigger focus guards [popover] Remove stray focus guards around trigger when modal Mar 17, 2026
@atomiks
atomiks marked this pull request as ready for review March 17, 2026 08:38
@atomiks
atomiks merged commit cf44d88 into mui:master Mar 19, 2026
7 checks passed
@atomiks
atomiks deleted the codex/popover-modal-focus-guards branch March 19, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: popover Changes related to the popover component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants