Replies: 1 comment 2 replies
-
This functionality with 4 guards was taken largely from this Sandbox, which allows non-modal focus management to work with React portals across browsers, especially Safari & iOS with VoiceOver which doesn't support
This was one of the most difficult things to implement and test, and to be honest, I can't really remember how exactly the logic works now lol 😅 The "before" |
Beta Was this translation helpful? Give feedback.
-
When using
<FloatingFocusManager modal={false}>
(+<FloatingPortal>
), I noticed two sets of extra DOM elements:<span data-type="inside">
(x2) before and after the floating element inside the portal target.<span data-type="outside">
(x2) and<span aria-owns="_portal-id_>">
after the reference element.I think I understand 1. It's probably necessary for moving focus back to the reference element when it escapes the floating element. And I'm ok with it, since it is out of the regular document flow.
However, I don't understand the need for 2 (and I couldn't find any documentation). My best guess is that it helps with very complex cases, like comboboxes, where the real focus stays on the reference element and the virtual focus is set using
aria-activedescendant
. But this is a very niche case; it is far more common for floating elements to be like dialogs, where the DOM focus itself is moved. Would it be possible to disable these extra DOM elements while keeping themodal={false}
behavior? These elements are undesirable because they are part of the main document and will break CSS selectors like:nth-child
and> * + *
.Beta Was this translation helpful? Give feedback.
All reactions