zag
zag copied to clipboard
Incorrect focus
🐛 Bug report
Opening the menu by clicking the trigger button sometimes activates :focus-visible despite not beeing a keyboard interaction.
💥 Steps to reproduce
- Go to the provided Stackblitz or change styling for the exampleon the website to apply the blue outline on
:focus-visibleinstead of:focus - Click on the button to open the menu.
- You see the blue outline applied despite using the mouse.
- Now click the other button effectively leaving keyboard interaction mode.
- When you click the menu button again it opens as expected without showing the outline.
- Press
Escto enter keyboard iinteraction mode again. The menu closes. - Click the menu button again and the outline returns.
💻 Link to reproduction
🧐 Expected behavior
:focus-visible is only triggered on keyboard interaction as it is the case for other components like select.
🌍 System information
| Software | Version(s) |
|---|---|
| Zag Version | latest |
| Browser | Chrome |
| Operating System | Linux |
This is not something we control, as calling element.focus() can sometimes show the focus outline.
When this becomes widely supported, it will no longer become an issue. https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#focusvisible