base-ui icon indicating copy to clipboard operation
base-ui copied to clipboard

[popover] Fix nested `openOnHover`

Open atomiks opened this issue 6 months ago • 2 comments

Fixes #1932

Possible questions:

  • Should the nested popover disable the useHover of the parent hovered popover like Menu does? This means it requires an outside press to dismiss rather than a hover out.
  • FloatingTree can't generalize between different floating components (e.g. Popover openOnHover -> Menu openOnHover will close the Popover unexpectedly). It is possible that dot point 1 would solve this if we detected it landed in a data-floating-ui-portal (but maybe not all cases where we land in a new popup should prevent closing the parent).

atomiks avatar May 19 '25 00:05 atomiks

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@1938

commit: a5bb1e4

pkg-pr-new[bot] avatar May 19 '25 00:05 pkg-pr-new[bot]

Deploy Preview for base-ui ready!

Name Link
Latest commit a5bb1e49aca4664fd2a828458dd5186c190ba45e
Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6835b0ba2c375b0008112a63
Deploy Preview https://deploy-preview-1938--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.

netlify[bot] avatar May 19 '25 00:05 netlify[bot]

FloatingTree can't generalize between different floating components (e.g. Popover openOnHover -> Menu openOnHover will close the Popover unexpectedly). It is possible that dot point 1 would solve this if we detected it landed in a data-floating-ui-portal (but maybe not all cases where we land in a new popup should prevent closing the parent).

We can introduce a "container" context across the library, similarly to how menu parent context works. Components that can have other components nested (like dialogs, toolbars, popovers, etc.) could set up a context the will make children aware if they are placed inside. Such context could expose methods such as close so that children can control parent's behavior to a degree.

michaldudak avatar May 27 '25 14:05 michaldudak