You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
After being clicked with a mouse, tab labels show the outline and have a background #3150
bugAn error in the Docusaurus core causing instability or issues with its executiondifficulty: starterIssues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.good first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.
If you click on a tab label with a mouse, the label shows the outline. If you then point the mouse elsewhere, the clicked tab label still shows var(--ifm-hover-overlay) as the background.
Using Chrome, go to v2.docusaurus.io/docs/markdown-features/#tabs, click on any of the tabs, the outline will be shown, and if you point the mouse elsewhere, the hover-overlay will still be the background of the tab label.
Expected behavior
The selected tab label should have the same look as the label of the tab, selected by default. There shouldn't be any difference between the label you just clicked on and the label you clicked on before clicking somewhere else, e.g. on a text or on the page background. No background, if the mouse isn't pointing at the label, should be shown, and no outline should be shown unless a keyboard or an assistive device is used for interacting with the page.
I would expect the outline to appear once I use the tab button or other keyboard buttons for the navigation, but not while I'm using only the mouse.
Actual Behavior
When I click on a tab label, it shows the outline and has a background until you click elsewhere.
In the latest Chrome, both the outline and the background are showed. In Edge and Firefox, the outline isn't being showed, but the background is there until you click somewhere else.
I'm not experienced with frontend at all and using Docusaurus for creating documentation for an API, and I avoided this behavior locally, but in a way that's obviously not the actual way to fix the bug. I created a TabsWrapper so I can put tags around all the tags:
changed the title [-]After being clicked with a mouse, tab labels show the outline in Chrome and backgrounds everywhere[/-][+]After being clicked with a mouse, tab labels show the outline and have a background[/+]on Jul 28, 2020
I'm not an accessibility expert, do you have a document that explains best practices in this regard and clearly says that an outline should not be displayed on a clicked element?
If someone knows exactly what to do, PRs are welcome
While writing this comment, I found that there is a recommendation of using :focus-visible, which is not yet supported by Chrome, but can be added using a polyfill from W3C's WICG.
The outline on a tab clicked with a mouse is something unexpected and leads to inconsistent behavior across different browsers.
The documents are saying that you shouldn't restrict users on what device they're using for the interactions (see this W3C recommendation), so basically the outline should be displayed when a keyboard or an assistive device is used for navigation.
(For this purpose, tabindex tags are being added so the browser knows where to navigate. On most pages, when you click on an element with a tabindex, you're being redirected to another page, so the outline is shown for a moment, but you don't notice that.)
But there are things like tabs. Before Docusaurus v2, the tabs hadn't had tabindexes, so the outline wasn't shown, but also you couldn't have accessed the tabs with a keyboard. In v2, you can, which is good, but Chrome focuses on everything clicked and displays an outline once you've clicked on a tab label with a mouse, which is pretty disconcerting.
Since Chrome is popular, websites use JS for avoiding the issue. E.g. if you click on a tab with a mouse here on GitHub, or on CloudFlare, it doesn't show the outline, and if you navigate using a keyboard, tabs show the outlines.
I think the solution would be something like importing the polyfill (I would create a PR but I don't really know how imports work in NodeJS) and adding this to the tabs style:
@mdfaizan7 thank you for the PR, but I don't think it would solve the issue.
It hides the outline from all the users, so you can't navigate with a keyboard or an assistive device anymore, and also leads to the hover-background being not shown when the tab is clicked but and the mouse is pointing at it.
The only way of solving the issue with the outline is to show the outline only when a user navigates using something that's not a mouse. The easiest way is, as I mentioned earlier, to import a :focus-visible polyfill and to add the CSS from above.
The part of the bug related to the background probably should be fixed just with removing background-color: var(--ifm-hover-overlay) from the tabs style, without adding background-color: transparent.
I have made another commit, this time I created an event listener to listen if the tab key is pressed or not. I also made a state variable which is a boolean. So if anytime the tab key is pressed, the value of that variable will be true and the outline will be shown. But if there is a mouse click then its value will be false, and the outlines will not be shown.
But there's an issue: users can navigate using other things, not only Tabs and Shift+Tabs on the keyboard, so it's not really good to rely only on those. The :focus-visible polyfill by W3C's WICG I mentioned earlier tracks how a user navigated to a newly focused element and listens to a lot of events, without anything specific for tabs. Maybe it's possible to use it instead or to copy its algorithm? There's also a package https://www.npmjs.com/package/use-focus-visible based on the polyfill which could be helpful.
Also, there's is a small bug: if you press Tab while being on the page, the outline will appear for a moment and then disappear the first time you click on the tab. Though this is not important if the logic of the polyfill will be used.
Thank you @Mihonarium for pointing out these points. I have refrained to use any other library or package to handle this bug. That's why I have not tried to use the polyfill package that you mentioned earlier.
I have now updated the code to listen to all the keys (except the meta, alt & ctrl key). So now, the users can use any key for navigating and the outline will be shown.
Also, I have also handled the other bug you mentioned. Now it doesn't occur on my device. Please see and tell me if you still experience this bug.
Thanks! Now everything looks good and I think works properly.
The other reason why I tried to suggest the usage of the polyfill is that there could be other similar issues with things showing the outline when they shouldn't, and the polyfill would allow to easily fix those issues with CSS without needing to add any new listeners to the keyboard events or write the same code. But that wasn't as important as just making everything work and look good, so you can probably merge the PR.
bugAn error in the Docusaurus core causing instability or issues with its executiondifficulty: starterIssues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.good first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.
Activity
Mihonarium commentedon Jul 28, 2020
If that's something that should be fixed, the fix should probably be implemented in https://github.com/facebook/docusaurus/tree/master/packages/docusaurus-theme-classic/src/theme/Tabs.
I'm not experienced with frontend at all and using Docusaurus for creating documentation for an API, and I avoided this behavior locally, but in a way that's obviously not the actual way to fix the bug. I created a
TabsWrapperso I can put tags around all the tags:And I added these to lines to the custom.css:
[-]After being clicked with a mouse, tab labels show the outline in Chrome and backgrounds everywhere[/-][+]After being clicked with a mouse, tab labels show the outline and have a background[/+]slorber commentedon Jul 29, 2020
Thanks, that looks like a visual bug to me.
We should fix it in Infima, the outline color of tabs should be in sync with the bottom border color
https://facebookincubator.github.io/infima/docs/components/tabs
Infima is not yet opensource
Mihonarium commentedon Jul 29, 2020
I mean, the bug is not the color of the outline, it's the outline itself being shown after a click.
In Chrome, the outline doesn't show up on https://facebookincubator.github.io/infima/docs/components/tabs/ if you click on a tab label, but it does on https://v2.docusaurus.io/docs/markdown-features/#tabs because there is a
tabindexand the default browser behavior is to show the outline for the elements in focus with atabindex.I'm not sure if it's possible to fix this without any JS while not losing accessibility.
slorber commentedon Jul 29, 2020
I'm not an accessibility expert, do you have a document that explains best practices in this regard and clearly says that an outline should not be displayed on a clicked element?
If someone knows exactly what to do, PRs are welcome
Mihonarium commentedon Jul 29, 2020
While writing this comment, I found that there is a recommendation of using
:focus-visible, which is not yet supported by Chrome, but can be added using a polyfill from W3C's WICG.The outline on a tab clicked with a mouse is something unexpected and leads to inconsistent behavior across different browsers.
The documents are saying that you shouldn't restrict users on what device they're using for the interactions (see this W3C recommendation), so basically the outline should be displayed when a keyboard or an assistive device is used for navigation.
(For this purpose,
tabindextags are being added so the browser knows where to navigate. On most pages, when you click on an element with a tabindex, you're being redirected to another page, so the outline is shown for a moment, but you don't notice that.)But there are things like tabs. Before Docusaurus v2, the tabs hadn't had tabindexes, so the outline wasn't shown, but also you couldn't have accessed the tabs with a keyboard. In v2, you can, which is good, but Chrome focuses on everything clicked and displays an outline once you've clicked on a tab label with a mouse, which is pretty disconcerting.
Since Chrome is popular, websites use JS for avoiding the issue. E.g. if you click on a tab with a mouse here on GitHub, or on CloudFlare, it doesn't show the outline, and if you navigate using a keyboard, tabs show the outlines.
There was a Chromium issue https://bugs.chromium.org/p/chromium/issues/detail?id=271023 in which Chromium team members say that developers should implement something to use JS to implement the desired behavior of when the outlines should be shown. And then there was a
:focus-visiblestandard, which is still not in Chrome but can already be used with a polyfill.I think the solution would be something like importing the polyfill (I would create a PR but I don't really know how imports work in NodeJS) and adding this to the tabs style:
mdfaizan7 commentedon Jul 30, 2020
I have made a PR for this issue in #3171
Mihonarium commentedon Jul 30, 2020
@mdfaizan7 thank you for the PR, but I don't think it would solve the issue.
It hides the outline from all the users, so you can't navigate with a keyboard or an assistive device anymore, and also leads to the hover-background being not shown when the tab is clicked but and the mouse is pointing at it.
The only way of solving the issue with the outline is to show the outline only when a user navigates using something that's not a mouse. The easiest way is, as I mentioned earlier, to import a :focus-visible polyfill and to add the CSS from above.
The part of the bug related to the background probably should be fixed just with removing
background-color: var(--ifm-hover-overlay)from the tabs style, without addingbackground-color: transparent.mdfaizan7 commentedon Jul 30, 2020
@Mihonarium thank you for the review.
I have made another commit, this time I created an event listener to listen if the tab key is pressed or not. I also made a state variable which is a boolean. So if anytime the tab key is pressed, the value of that variable will be true and the outline will be shown. But if there is a mouse click then its value will be false, and the outlines will not be shown.
Mihonarium commentedon Jul 30, 2020
👍 Good job!
But there's an issue: users can navigate using other things, not only Tabs and Shift+Tabs on the keyboard, so it's not really good to rely only on those. The :focus-visible polyfill by W3C's WICG I mentioned earlier tracks how a user navigated to a newly focused element and listens to a lot of events, without anything specific for tabs. Maybe it's possible to use it instead or to copy its algorithm? There's also a package https://www.npmjs.com/package/use-focus-visible based on the polyfill which could be helpful.
Also, there's is a small bug: if you press Tab while being on the page, the outline will appear for a moment and then disappear the first time you click on the tab. Though this is not important if the logic of the polyfill will be used.
Mihonarium commentedon Jul 30, 2020
Locally, I was able to completely resolve the issue by adding 'https://unpkg.com/[email protected]/dist/focus-visible.min.js' to the scripts in the docusaurus config and by adding the CSS from this comment to the custom.css file.
So if it's possible to import the package from Tabs, that would probably work. (I don't know how NodeJS packages work so can't make a PR)
mdfaizan7 commentedon Jul 31, 2020
Thank you @Mihonarium for pointing out these points. I have refrained to use any other library or package to handle this bug. That's why I have not tried to use the polyfill package that you mentioned earlier.
I have now updated the code to listen to all the keys (except the meta, alt & ctrl key). So now, the users can use any key for navigating and the outline will be shown.
Also, I have also handled the other bug you mentioned. Now it doesn't occur on my device. Please see and tell me if you still experience this bug.
Mihonarium commentedon Jul 31, 2020
Thanks! Now everything looks good and I think works properly.
The other reason why I tried to suggest the usage of the polyfill is that there could be other similar issues with things showing the outline when they shouldn't, and the polyfill would allow to easily fix those issues with CSS without needing to add any new listeners to the keyboard events or write the same code. But that wasn't as important as just making everything work and look good, so you can probably merge the PR.