Skip to content

feat[popover]:added trigger ref to support external trigger outside root #2168

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

piyushzala158
Copy link

@piyushzala158 piyushzala158 commented Jun 25, 2025

Issue: #2157

Copy link

pkg-pr-new bot commented Jun 25, 2025

Open in StackBlitz

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

commit: 4f2f582

@mui-bot
Copy link

mui-bot commented Jun 25, 2025

Bundle size report

Bundle Parsed Size Gzip Size
@base-ui-components/react 🔺+130B(+0.04%) 🔺+102B(+0.11%)

Details of bundle changes

Generated by 🚫 dangerJS against 4f2f582

Copy link

netlify bot commented Jun 25, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 4f2f582
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/685d5838123f4900086975cb
😎 Deploy Preview https://deploy-preview-2168--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.

@oleksandr-danylchenko
Copy link

Thank you, @piyushzala158!
Do I understand correctly that the reference passed down to the useFloatingRootContext will get its aria attributes and event listeners properly populated?

@piyushzala158
Copy link
Author

Thank you, @piyushzala158! Do I understand correctly that the reference passed down to the useFloatingRootContext will get its aria attributes and event listeners properly populated?

Yes

Co-authored-by: Oleksandr Danylchenko <68850090+oleksandr-danylchenko@users.noreply.github.com>
Signed-off-by: Piyush Zala <99941375+piyushzala158@users.noreply.github.com>
@atomiks
Copy link
Contributor

atomiks commented Jun 25, 2025

Thanks for the contribution @piyushzala158

Right now, though, this isn't going to work 😅: the trigger's props (getReferenceProps) are generated inside Popover.Root, and they can't be passed to the external trigger without bubbling them using an effect.

const { getReferenceProps, getFloatingProps } = useInteractions([hover, click, dismiss, role]);

We discussed this somewhat briefly yesterday and thought something like Toast's API could possibly work for things like Dialogs and Popovers.

This means you render your Popover(s) high up in the tree and use a hook to "create" them by passing structured data that the renderer uses as a template.

That said, I don't know if this solves @oleksandr-danylchenko's use case with the [data-page-family-id] needing to be query selected?

@oleksandr-danylchenko
Copy link

oleksandr-danylchenko commented Jun 26, 2025

We discussed this somewhat briefly yesterday and thought something like Toast's API could possibly work for things like Dialogs and Popovers.

This means you render your Popover(s) high up in the tree and use a hook to "create" them by passing structured data that the renderer uses as a template.

I like this idea 🙌🏻
That provider can expose a context with methods like popover(anchorEl, {}), or popoverManager.add(anchorEl, {}). That way, we'll also be able to handle the presence of just a single popover at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants