Skip to content

Conversation

@boka-inuits
Copy link
Contributor

@boka-inuits boka-inuits commented Oct 22, 2025

Hi @TotomInc!
This PR is opened to resolve a problem with menu positioning in modals and in general. Those changes will make the user experience better and comfortable.

A link to reproduce issues I wanted to resolve with floating-ui. As you can see, it's not calculating coordinates correctly when using the native dialog or if our modal has a scroll (second example). I was trying to solve it with a fixed position for the menu, but it did not fully resolve the issue. It's problematic for scrollable pages with and without a fixed position.
https://play.vuejs.org/#eNrtWPtv20Qc/1eO8MPSqXbSdi1g0jJWKti0sWmtkBBB6GyfE7dnn3V3Thq6/O987mHHefQxIZCQqKo0d/d9v7+9631fVeGsZr2oN1KJzCtNFNN1RTgtJ6fjnlbj3tm4zItKSE3uiGQZWZJMioKMe8Ab975tX3+p2SXjLNGd96NA2asgEQAqWam7GO9ESnkDHQ7s0UhjYcZlIkqlyYzympFTw3qktMzLCflEyprzs7753AOoA0xzysXkIyR0wD9dvXv7g7274KwA63vwcmUZv69Y6TD7GeWKGYBxmdVlonNREoFnR62/R+7GJVnxC62I34VqKuaWVN/gLtfQEy4UewTfwjS4o4HzB6yPg2ZFxalmOBEySvMZCFKl4KGKTmAve4+XuNbacnOPRugg1uW4R14mPE9u/J0TBGhWae81dzkaOBqWr6Xp5DSGAXYrNEg2XJJaaVEE7qmVBZjTozNPeyFqSTI6EzLXzAZXDblHA0A0fADfRlBzQ8gsKETKOLhYI417q6dIVMa0RoLfVrcEUcppzHhEnr2hM3pprfhs38URLq/VM7Lc341wtajYFoJ+AOEjVO+ASnO8F/hynmddaGXPa+C/dxWExxM2FTxlEjp6S1JSSTGRtChMJjSW7KJpAJr0Ak644ZoV0IbvXJauAAZdt1TeiyyNyN2dT8hPn5CzJVIagbBcjgZVFwPZVrcsqM0AV0ga9k2gtlHZyQ8AnptTJxI90sDQbUJ94JRaxekTYn891bU0AbWWA/Z5OwVcoULAsXKdiiMOYbeI2xryd5LBJLnSC25IT1k+meqInAyH1S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+d0CzV2PaqhQafgdzdGf3aLQHITijJVme2X3XITDQa+EtccD3Me/59WDc24vITORpg9bZr6douJy98vXw3EweBvOdqBW7mCG2/NKdZ6AYOquQ09NTwlAGpATAlb3bs1L0Vxwf3MaJHU2a+QLZB8PFIl2sFnIzLM2C3KzORvPO1uwGzKaCd7eUHbp0F4nu/LUxpXanMMUx2Zi5cNdg1Xw345QT/r7ZiiDdKpbixo/E6z1noxzaYpKXiKSmcD3alHb1INswA2xHBep+Zwh6aED6M7AVwwxtw1XlXjPQdj+YT8HksweFJ3X+J08Tx84Kj/R/QtYGc3tjelyGYhERWmvR6PxfaC5/QHJT0lB9jsLj8OCot/wLQZXANA==

That would be nice if you could merge it. If you don't want to add an extra dep, we can discuss further how to resolve it
That would also resolve #330

@vercel
Copy link

vercel bot commented Oct 22, 2025

Someone is attempting to deploy a commit to the tcaweb Team on Vercel.

A member of the Team first needs to authorize it.

@TotomInc
Copy link
Owner

Hi @boka-inuits, thanks for your contribution.

I'll review it soon. 🙂

@vercel
Copy link

vercel bot commented Oct 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
vue3-select-component Ready Ready Preview Comment Oct 23, 2025 7:08pm

@TotomInc
Copy link
Owner

Also fixes #180

@TotomInc TotomInc merged commit 5071f95 into TotomInc:master Oct 23, 2025
2 checks passed
@TotomInc
Copy link
Owner

Deployed in v0.13.0

@thiervoj
Copy link

I everyone, I just tried updating the library from 0.12.3 to 0.13.0 and while the new positioning feature is working fine in theory, I feel like it's lacking a way of changing styles depending on the menu position (top / bottom)
Below are some examples with custom styling that are broken by the update in the new position :

image Working fine image Broken

The easiest way that I can see to fix that issue would be to apply a class to the menu, that would be toggled depending on its positioning, allowing users to set styles that differ depending on the position. This way, the class would allow my example to look fine in both cases, changing the border-radius accordingly.

But I don't know if that's something that can be easily done using Floating UI @TotomInc

@TotomInc
Copy link
Owner

I see what you mean @thiervoj, I'll consider adding something along data-state-position="top|bottom". I believe the top/bottom state can be retrieved from floating-ui.

Then, you'll be able to use the data-state-position attribute for custom styling.

What do you think?

@boka-inuits
Copy link
Contributor Author

I see what you mean @thiervoj, I'll consider adding something along data-state-position="top|bottom". I believe the top/bottom state can be retrieved from floating-ui.

Then, you'll be able to use the data-state-position attribute for custom styling.

What do you think?

yes, it's possible to get a position from floating ui. Something like that

      apply({ elements, rects, placement }) {
        // top, bottom, left, right
        const direction = placement?.split("-")[0];
        // `elements.floating` is the html element, so you can add attributes/classes, whatever you want to it according to its direction

        Object.assign(elements.floating.style, {
          width: `${Math.max(0, rects.reference.width)}px`,
        });
      },

@thiervoj
Copy link

Looks perfect to me, thanks @TotomInc !

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

With teleport="body" and a scrolled page, the list is not correctly positionned

3 participants