-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Ensure moving focus within a Portal
component, does not close the Popover
component
#2492
Commits on May 12, 2023
-
abstract resolving root containers to hook
This way we can reuse it in other components when needed.
Configuration menu - View commit details
-
Copy full SHA for 26cd5e1 - Browse repository at this point
Copy the full SHA 26cd5e1View commit details
Commits on May 15, 2023
-
allow registering a
Portal
component to a parentThis allows us to find all the `Portal` components that are nested in a given component without manually adding refs to every `Portal` component itself. This will come in handy in the `Popover` component where we will allow focus in the child `Portal` components otherwise a focus outside of the `Popover` will close the it. In other components we often crawl the DOM directly using `[data-headlessui-portal]` data attributes, however this will fetch _all_ the `Portal` components, not the ones that started in the current component.
Configuration menu - View commit details
-
Copy full SHA for f965772 - Browse repository at this point
Copy the full SHA f965772View commit details -
allow focus in portalled containers
The `Popover` component will close by default if focus is moved outside of it. However, if you use a `Portal` comopnent inside the `Popover.Panel` then from a DOM perspective you are moving the focus outside of the `Popover.Panel`. This prevents the closing, and allows the focus into the `Portal`. It currently only allows for `Portal` components that originated from the `Popover` component. This means that if you open a `Dialog` component from within the `Popover` component, the `Dialog` already renders a `Portal` but since this is part of the `Dialog` and not the `Popover` it will close the `Popover` when focus is moved to the `Dialog` component.
Configuration menu - View commit details
-
Copy full SHA for a764fb3 - Browse repository at this point
Copy the full SHA a764fb3View commit details -
ensure
useNestedPortals
register/unregister with the parentThis ensures that if you have a structure like this: ```jsx <Dialog> {/* Renders a portal internally */} <Popover> <Portal> {/* First level */} <Popover.Panel> <Menu> <Portal> {/* Second level */} <Menu.Items> {/* ... */} </Menu.Items> </Portal> </Menu> </Popover.Panel> </Portal> </Popover> </Dialog> ``` That working with the `Menu` doesn't close the `Popover` or the `Dialog`.
Configuration menu - View commit details
-
Copy full SHA for e58c7d2 - Browse repository at this point
Copy the full SHA e58c7d2View commit details -
cleanup
useRootContainers
hookThis will allow you to pass in portal elements as well. + cleanup of the resolving of all DOM nodes.
Configuration menu - View commit details
-
Copy full SHA for bb468cc - Browse repository at this point
Copy the full SHA bb468ccView commit details -
Configuration menu - View commit details
-
Copy full SHA for 68a9f05 - Browse repository at this point
Copy the full SHA 68a9f05View commit details -
expose
contains
function fromuseRootContainers
Shorthand to check if any of the root containers contains the given element.
Configuration menu - View commit details
-
Copy full SHA for 9a23cc5 - Browse repository at this point
Copy the full SHA 9a23cc5View commit details -
Configuration menu - View commit details
-
Copy full SHA for d7ad2f4 - Browse repository at this point
Copy the full SHA d7ad2f4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5ceed37 - Browse repository at this point
Copy the full SHA 5ceed37View commit details
Commits on May 16, 2023
-
re-order use-outside-click logic
To make it similar between React & Vue
Configuration menu - View commit details
-
Copy full SHA for fb01556 - Browse repository at this point
Copy the full SHA fb01556View commit details -
Configuration menu - View commit details
-
Copy full SHA for cb9b6e4 - Browse repository at this point
Copy the full SHA cb9b6e4View commit details
Commits on May 19, 2023
-
Configuration menu - View commit details
-
Copy full SHA for f46368a - Browse repository at this point
Copy the full SHA f46368aView commit details