Akryum / floating-vue

💬 Easy tooltips, popovers, dropdown, menus... for Vue
https://floating-vue.starpad.dev/
MIT License
3.26k stars 333 forks source link

feat: expose global `recomputeAllPoppers` helper #1010

Closed antfu closed 6 months ago

antfu commented 6 months ago

Currently, Floating Vue is already calling this function on the window resize event. While in some cases, user might want to trigger this manually in cases like tab switch or the others.

For example https://twoslash.netlify.app/refs/notations, when you click the Input Code on the first tab group, you will see the popup still persist.

netlify[bot] commented 6 months ago

Deploy Preview for v-tooltip ready!

Name Link
Latest commit 72c0e09624a8ee6394388bc11e095a42ea82e67a
Latest deploy log https://app.netlify.com/sites/v-tooltip/deploys/65a565c829e63400080e3e2d
Deploy Preview https://deploy-preview-1010--v-tooltip.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 site configuration.

Akryum commented 6 months ago

I'm not sure I understand the link between the issue and recomputeAllPoppers. Would the correct behavior be to hide the popper?

antfu commented 6 months ago

Current behavior:

https://github.com/Akryum/floating-vue/assets/11247099/99da265f-f169-42b4-b9d5-31ae9afa29ec

Expected behavior:

https://github.com/Akryum/floating-vue/assets/11247099/62d19842-f094-4471-97aa-d5145753eb27

This PR itself does not fix the issue but adds the capability of it. Users could add the call to recomputeAllPoppers on tab switch.

antfu commented 6 months ago

A temporary workaround we have: https://github.com/twoslashes/twoslash/commit/0e8cecae215ffe43af989e394d44b447f4e25a32

Akryum commented 6 months ago

Wouldn't it be better to observe visibility on target?

antfu commented 6 months ago

Wouldn't it be better to observe visibility on target?

That would do, are you ok with enabling it by default for listening to every element?