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

fix(Tabs): add visible focus indicator on active tabs #690

Merged
merged 8 commits into from
Sep 27, 2023
Merged

fix(Tabs): add visible focus indicator on active tabs #690

merged 8 commits into from
Sep 27, 2023

Conversation

HigherOrderLogic
Copy link
Contributor

Closes #685.

@vercel
Copy link

vercel bot commented Sep 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview Sep 22, 2023 0:14am

@benjamincanac
Copy link
Member

I've tried this already but unfortunately, the focus appears when clicking. This is the reason I removed it in the first place.

@HigherOrderLogic
Copy link
Contributor Author

I've tried this already but unfortunately, the focus appears when clicking. This is the reason I removed it in the first place.

So should I close this then?

@benjamincanac
Copy link
Member

Not sure, is there no way to achieve this without having the focus-visible on click?

@HigherOrderLogic
Copy link
Contributor Author

Maybe this is caused by another piece of css in the component? Because the Tailwind docs state that Style an element when it has been focused using the keyboard using the focus-visible modifier.

@HigherOrderLogic
Copy link
Contributor Author

After messing around, I found out that the outline only appears after you have moving around using Tab key.

@benjamincanac
Copy link
Member

If you go the preview url, scroll down a bit and click on the tabs, the focus appears without having pressed any key.

@matteason
Copy link

This issue in Headless UI looks relevant: tailwindlabs/headlessui#1694

Basically a manual focus() call (probably https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-vue/src/components/tabs/tabs.ts#L405) seems to trigger the browser to think that the focus has been performed via the keyboard rather than the mouse, so focus-visible is enabled. Interestingly, if you click on another interactive element (for example the search box) before clicking the tabs, the focus ring is not visible.

@HigherOrderLogic
Copy link
Contributor Author

This should be working now. The tradeoff is that there's one more package for users when they install the module.

@benjamincanac
Copy link
Member

I don't mind adding this plugin.

Maybe the focus should be on all the tabs instead of only the selected one?

@HigherOrderLogic
Copy link
Contributor Author

Initialy, I tried that. But when I focus on an inactived tab using keyboard and press Enter, nothing change.

@matteason
Copy link

I think showing the focus ring on the selected tab is the correct behaviour - it's the tab itself that has focus rather than the tablist, and it reflects the behaviour of the WAI tabs example

@benjamincanac
Copy link
Member

Sorry but #692 introduced quite a few changes, would you mind fixing the conflicts?

@HigherOrderLogic
Copy link
Contributor Author

Sorry but #692 introduced quite a few changes, would you mind fixing the conflicts?

I messed up pretty hard but it should be okay now.

@benjamincanac benjamincanac changed the title feat(Tabs): add visible focus indicator on active tabs fix(Tabs): add visible focus indicator on active tabs Sep 27, 2023
@benjamincanac benjamincanac merged commit be734fc into nuxt:dev Sep 27, 2023
1 check passed
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.

No visible focus indicator on tabs
3 participants