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

(v2.0.0-alpha.4) Listbox: Scrollbar offset correction issues #2948

Open
simonedelmann opened this issue Jan 27, 2024 · 0 comments
Open

(v2.0.0-alpha.4) Listbox: Scrollbar offset correction issues #2948

simonedelmann opened this issue Jan 27, 2024 · 0 comments

Comments

@simonedelmann
Copy link

What package within Headless UI are you using?

@headlessui/react@2.0.0-alpha.4

What browser are you using?

Chrome + Safari

Reproduction URL

https://github.com/simonedelmann/headlessui-demo

Describe your issue

If HeadlessUI opens a listbox/dropdown/etc., there are two styles applied to the body: overflow: hidden; padding-right: 15px
overflow: hidden; removes the scrollbar, so there is a padding applied, which is calculated by the scrollbar's width. This should avoid shifts in the layout due to the missing scrollbar.

I have two issues with this:

Issue 1: Scrollbar offset if height is exactly 100vh

If the page's height exactly equals the inner height of the browser window (e.g. Tailwind class min-h-screen), there is no scrollbar shown. (There is nothing to scroll obviously.) But padding-right: 15px is still applied.

(If the page's height is smaller than the browser window, there is padding-right: 0px applied instead. This should also be the case for page height = browser height.)

Issue 2: ListboxOptions also gets scrollbar offset

If ListboxOptions has the class overflow-y-scroll (see here), the same 15px scrollbar offset will be added to ListboxOptions, even though there never was any scrollbar at all.

This happens especially when using the Catalyst UI Listbox component. I also have this issue on https://catalyst.tailwindui.com

Screenshots
Bildschirmfoto 2024-01-27 um 17 06 02
This is a screenshot from the minimal reproduction linked above. The two red bars show, where the 15px offset correction is applied.

Bildschirmfoto_2024-01-27_um_12 12 35
This is a screenshot from the Catalyst docs, where you can also see the padding.

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

No branches or pull requests

1 participant