Skip to content

Adds initialFocusSkip option to focus-trap#3163

Open
alex-e-leon wants to merge 1 commit into
chakra-ui:mainfrom
alex-e-leon:add-initial-focus-skip-to-focus-trap
Open

Adds initialFocusSkip option to focus-trap#3163
alex-e-leon wants to merge 1 commit into
chakra-ui:mainfrom
alex-e-leon:add-initial-focus-skip-to-focus-trap

Conversation

@alex-e-leon

Copy link
Copy Markdown

Closes #3161

📝 Description

Adds a new option to focus-trap that allows one to define elements that should avoid being the initial focused element when a focus trap initializes. I've added it as a new option so that the feature is opt-in and the regular behaviour should remain unchanged. I'm also open to other approaches but thought a proof of concept would help.

⛳️ Current behavior (updates)

the initial focused element in focus-trap must be manually specified.

🚀 New behavior

elements can now be marked to avoid being the initial focused elements - allowing elements like tooltips or other elements with distracting focused states to mark themselves as preferring not to be initially focused.

💣 Is this a breaking change (Yes/No):

No

@changeset-bot

changeset-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a34cf11

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
zag-nextjs Ready Ready Preview Jun 3, 2026 12:26pm
zag-solid Ready Ready Preview Jun 3, 2026 12:26pm
zag-svelte Ready Ready Preview Jun 3, 2026 12:26pm
zag-vue Ready Ready Preview Jun 3, 2026 12:26pm
zag-website Ready Ready Preview Jun 3, 2026 12:26pm

Request Review

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.

Support data-no-autofocus in focusTrap or similar

1 participant