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

Hidden 1px button break layout #1491

Closed
Intaria opened this issue May 22, 2022 · 1 comment · Fixed by #1493
Closed

Hidden 1px button break layout #1491

Intaria opened this issue May 22, 2022 · 1 comment · Fixed by #1493
Assignees

Comments

@Intaria
Copy link

Intaria commented May 22, 2022

If some of headlessui componens (that created this button) placed inside container with flex space-* classes, then first element will be hidden button, and all others will get margin:

Code example: https://codesandbox.io/s/loving-water-5s30ee

@RobinMalfait
Copy link
Collaborator

RobinMalfait commented May 23, 2022

Hey! Thank you for your bug report!
Much appreciated! 🙏

Aha, good catch. The issue is that you are using a very old version of Tailwind CSS, in fact you are referencing the Tailwind UI bundled version (https://unpkg.com/@tailwindcss/ui/dist/tailwind-ui.min.css). This is not necessary anymore, more on this topic here:

The issue with that version is that it is defining the space-y- utilities as:

.space-y-10 > :not(template) ~ :not(template) {}

Whereas the newest Tailwind CSS is using this instead:

.space-y-10 > :not([hidden]) ~ :not([hidden]) {}

This is where we check for the hidden attribute instead. Now, for Headless UI, the hidden button is there to capture focus and forward it to a Tab if they are not immediately ready yet (some implementation details). But because of this reason we can't use the hidden attribute because it will not be able to receive the focus.

That said this is an implementation detail and shouldn't cause issues so a fix will be ready in #1493

Either way, in both cases I would recommend you to use gap-10 or gap-y-10 instead of the space-xxx utilities instead because they use the native gap property which is pretty well supported these days and is not a "hack" with margins.

So some action points for you:

RobinMalfait added a commit that referenced this issue May 23, 2022
…1493)

* only render the `FocusSentinel` if required

Fixes: #1491

* update changelog
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 a pull request may close this issue.

2 participants