Skip to content

[popups] initialFocus and finalFocus functions #2536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

atomiks
Copy link
Contributor

@atomiks atomiks commented Aug 19, 2025

@vladmoroz this should solve your concerns with managing focus.

// Do not move focus at all
<Dialog.Popup initialFocus={null} />
<Dialog.Popup finalFocus={null} />

// Move focus to a custom element at focus time
<Dialog.Popup initialFocus={(openType) => myElement} />
<Dialog.Popup finalFocus={(closeType) => myElement} />

// Focus yourself, with custom options (void return)
<Dialog.Popup initialFocus={() => myElement.focus()} />

Breaking: if you specify a function, return the element directly instead of a ref

@atomiks atomiks added type: new feature Expand the scope of the product to solve a new problem. scope: dialog This is the name of the generic UI component, not the React module! labels Aug 19, 2025
Copy link

pkg-pr-new bot commented Aug 19, 2025

vite-css-base-ui-example

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

commit: cdc7894

@mui-bot
Copy link

mui-bot commented Aug 19, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 🔺+1.29KB(+0.41%) 🔺+480B(+0.49%)

Details of bundle changes

Generated by 🚫 dangerJS against cdc7894

Copy link

netlify bot commented Aug 19, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f06c500
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/68a40ce3bb5d9000083215a5
😎 Deploy Preview https://deploy-preview-2536--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.

Copy link

netlify bot commented Aug 19, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit cdc7894
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/68a5bf18c67e290008875ff8
😎 Deploy Preview https://deploy-preview-2536--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 marked this pull request as ready for review August 20, 2025 08:42
@atomiks atomiks added scope: menu This is the name of the generic UI component, not the React module! scope: alert dialog This is the name of the generic UI component, not the React module! scope: popover This is the name of the generic UI component, not the React module! labels Aug 20, 2025
@atomiks atomiks added the breaking change Introduces changes that are not backward compatible. label Aug 20, 2025
@atomiks atomiks force-pushed the feat/focus-fns branch 3 times, most recently from 17ba3e4 to 5cc951c Compare August 20, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Introduces changes that are not backward compatible. scope: alert dialog This is the name of the generic UI component, not the React module! scope: dialog This is the name of the generic UI component, not the React module! scope: menu This is the name of the generic UI component, not the React module! scope: popover This is the name of the generic UI component, not the React module! type: new feature Expand the scope of the product to solve a new problem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants