8000 fix(FloatingFocusManager): check for blurring to nested elements inside the React tree without `FloatingTree` by atomiks · Pull Request #3318 · floating-ui/floating-ui · GitHub
[go: up one dir, main page]

Skip to content

fix(FloatingFocusManager): check for blurring to nested elements inside the React tree without FloatingTree #3318

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

Merged
merged 2 commits into from
May 26, 2025

Conversation

atomiks
Copy link
Collaborator
@atomiks atomiks commented May 16, 2025

Fixes #3060

When the nested floating element isn't nested inside the parent's portal element (changing the root on FloatingPortal to escape this behavior), it closes unexpectedly because focusout is triggered and the handler doesn't have knowledge of the React tree, only the DOM tree.

This PR changes this by using the same capture phase technique to let the handler know it's inside the React tree, to avoid needing to setup FloatingTree. This is how outside press is handled already.

One caveat is that it requires useDismiss to be used in conjunction with FloatingFocusManager to work because FloatingFocusManager can't assign React props. (It seems the closeOnFocusOut logic in FloatingFocusManager could better live inside useDismiss instead - a possible refinement for v1).

Solving nested useHover still requires FloatingTree at this time, but I need to investigate how that could work.

Copy link
changeset-bot bot commented May 16, 2025

🦋 Changeset detected

Latest commit: 13217d2

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

This PR includes changesets to release 2 packages
Name Type
@floating-ui/react Patch
website 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

Copy link
netlify bot commented May 16, 2025

Deploy Preview for vibrant-gates-22c214 ready!

Name Link
🔨 Latest commit 13217d2
🔍 Latest deploy log https://app.netlify.com/projects/vibrant-gates-22c214/deploys/6826e1716e9c3100089ee201
😎 Deploy Preview https://deploy-preview-3318--vibrant-gates-22c214.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
pkg-pr-new bot commented May 16, 2025

Open in StackBlitz

@floating-ui/core

npm i https://pkg.pr.new/@floating-ui/core@3318

@floating-ui/dom

npm i https://pkg.pr.new/@floating-ui/dom@3318

@floating-ui/react

npm i https://pkg.pr.new/@floating-ui/react@3318

@floating-ui/react-dom

npm i https://pkg.pr.new/@floating-ui/react-dom@3318

@floating-ui/react-native

npm i https://pkg.pr.new/@floating-ui/react-native@3318

@floating-ui/utils

npm i https://pkg.pr.new/@floating-ui/utils@3318

@floating-ui/vue

npm i https://pkg.pr.new/@floating-ui/vue@3318

commit: 13217d2

@atomiks atomiks merged commit d723f38 into master May 26, 2025
10 checks passed
@atomiks atomiks deleted the fix/blur-portals branch May 26, 2025 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
478F
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FloatingFocusManger's closeOnFocusOut closes incorrectly when nested floating elements are portaled
1 participant
0