Skip to content
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

Popover.Provider similar to Tooltip.Provider #720

Open
raymonddaikon opened this issue Oct 3, 2024 · 6 comments
Open

Popover.Provider similar to Tooltip.Provider #720

raymonddaikon opened this issue Oct 3, 2024 · 6 comments
Labels
enhancement An improvement to an existing feature/component next

Comments

@raymonddaikon
Copy link

Describe the feature in detail (code, mocks, or screenshots encouraged)

Would be nice to have a Popover.Provider to enable groups of popovers similar to how tooltips are handled. I'd like to have popovers seamlessly transition into each other (if their triggers are adjacent) instead of closing and opening a new one. Currently this is partially possible with Tooltips if you use multiple triggers under a single Root with a single Tooltip.Content and the customAnchor prop.

What type of pull request would this be?

Enhancement

Provide relevant links or additional information.

No response

@huntabyte
Copy link
Owner

Can you provide some more detail/images/video about what you're looking to accomplish?

I'll be upfront and say it's unlikely we'll have a Popover.Provider, but perhaps there's a way we can make what you're trying to do a bit easier, I just need to see it.

@huntabyte huntabyte added enhancement An improvement to an existing feature/component next labels Oct 3, 2024
@raymonddaikon
Copy link
Author

Sure, I found a good example of what I'm trying to accomplish in the floating-ui issues here. I believe this should be relatively straight-forward to accomplish in svelte. I'll update once I get something working with svelte floating-ui.

@raymonddaikon
Copy link
Author

raymonddaikon commented Oct 3, 2024

Got it working pretty easily with floating ui

Screen.Recording.2024-10-02.at.18.57.09.mov

and the code I used to get this effect, note: I'm using the watch utility from runed.

 let navTooltipOpen = $state(false)
 let navTooltipContent = $state('')
 let tooltipAnchor = $derived(document.getElementById(navTooltipContent))
const floating = useFloating({
   whileElementsMounted: autoUpdate,
   get open() {
     return navTooltipOpen
   },
   onOpenChange: (v) => (navTooltipOpen = v),
   placement: 'right',
   get middleware() {
     return [offset(16)]
   },
 })
 watch(
   () => navTooltipContent,
   () => {
     floating.elements.reference = tooltipAnchor
   },
 )

@huntabyte
Copy link
Owner

huntabyte commented Oct 5, 2024

Mind dropping a stackblitz/repo or similar to demonstrate this behavior using Svelte 5 and floating UI? It will help me determine/test some ideas I may have to solve this 😃

@raymonddaikon
Copy link
Author

raymonddaikon commented Oct 8, 2024

Sure thing, here's a sveltelab repl, let me know if there's anything wrong with it. Edit: Sveltelab is kind of weird when coming to picking up document, so initially comment out the tooltipAnchor line then uncomment it when the container fully loads.

@shyakadavis
Copy link
Contributor

Allow me to chime in:

@huntabyte, @anatolzak once did something similar that I copied for a project.

Hope it helps, at least in regard to comparing against @raymonddaikon's example for the best approach forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement to an existing feature/component next
Projects
None yet
Development

No branches or pull requests

3 participants