-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 still enables :focus-visible
state in v1.7.15
#2583
Comments
Hey, thank you for this bug report! 🙏 Yep there is a tiny bit more work involved. The problem is that this is default browser behaviour that we can't really change. The moment you programmatically focused something, the browser will show an outline and there is nothing we can do about that part (yet). However, what we can do (and what we introduced in that PR) is a custom data attribute that we set on the We also made it a bit easier if you use our It also looks like you are using Tailwind CSS v2, so we can update your existing selector to make use of this data attribute manually instead: - *:focus:not(:focus-visible) {
+ *:focus:not(:focus-visible),
+ html:not([data-headlessui-focus-visible]) *:focus {
outline: none !important;
} I've updated your StackBlitz to see this in action: https://stackblitz.com/edit/nextjs-oiv43d?file=styles%2Fglobals.css Hope this helps! |
Thank you @RobinMalfait , Your CSS code solved my problem! But I still have a question, when I use TailwindCSS 3, if I use <button class="ui-focus-visible:ring-2 ui-focus-visible:ring-offset-2 focus:outline-none">
My Button
</button> Then keyboard tab cannot get visible outline. I reproduced it here: https://stackblitz.com/edit/nextjs-3keep4?file=package.json,styles%2Fglobals.css,pages%2Findex.js Is there anything I did wrong? |
This is still an issue in Tailwind 3. |
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v1.7.15
What browser are you using?
Safari, Chrome
Reproduction URL
https://stackblitz.com/edit/nextjs-nexl9h?file=README.md
Describe your issue
When click Popover Button using mouse, it still show the outline which should only be shown when using keyboard tab. This issue was mentioned here #1694 , and the PR has been merged #2347 in v1.7.14.
But I still met the same problem when I was using v1.7.15. (See previous reproduction URL)
The text was updated successfully, but these errors were encountered: