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

Add focus visibility on tabs with pills #32357

Closed
wants to merge 38 commits into from

Conversation

mayralgr
Copy link

@mayralgr mayralgr commented Dec 7, 2020

@mayralgr mayralgr requested a review from a team as a code owner December 7, 2020 02:48
@mayralgr mayralgr marked this pull request as draft December 7, 2020 03:04
@mayralgr mayralgr marked this pull request as ready for review December 7, 2020 03:19
@patrickhlauke
Copy link
Member

I think this should specifically target only the pills nav links, as this PR in its current form affects all nav links - see, for instance, the top navigation in the header (Home, Docs, Examples ...) https://deploy-preview-32357--twbs-bootstrap.netlify.app/

Nav with hovered 'examples' showing the blue hover outline

scss/_variables.scss Outdated Show resolved Hide resolved
@mayralgr mayralgr requested review from patrickhlauke and removed request for a team December 7, 2020 14:24
@mayralgr
Copy link
Author

mayralgr commented Dec 9, 2020

@patrickhlauke changes where made, let me know if another change is needed

Copy link
Member

@mdo mdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be setting focus styles (the box-shadow) on hover. Will review in more depth likely after beta 2.

@mayralgr mayralgr requested a review from mdo December 10, 2020 16:17
@mayralgr
Copy link
Author

@mdo I left it just with the focus. Let me know if it is the correct approach.

@patrickhlauke
Copy link
Member

We shouldn't be setting focus styles (the box-shadow) on hover. Will review in more depth likely after beta 2.

well, it was just replicating what buttons do...i personally wouldn't have minded.

@patrickhlauke
Copy link
Member

beyond that though, https://deploy-preview-32357--twbs-bootstrap.netlify.app/docs/5.0/components/navs-tabs/ looks good to me

@mayralgr
Copy link
Author

@mdo is the anything else needed ? Thank you!

@patrickhlauke
Copy link
Member

I think the doubling up I saw was because outline wasn't reset when box-shadow was added.

ah gotcha, we can fix it just for the pill ones, yes

@mayralgr
Copy link
Author

Hi guys I did this minor change but I am having trouble with the tests, as I left it I think I need a rebase or something ( I try but still gives an error ) any help ? 😅

@patrickhlauke
Copy link
Member

i think you forgot to git pull changes that were made to your branch here (as a result of rebasing/merging in changes here on github) before making the latest change, so your PR suddenly included lots of reverts of things that blew the tests up. i think i managed to manually fix it

@XhmikosR
Copy link
Member

XhmikosR commented Feb 9, 2021

Haven't looked at it too close, but it seems like the outline results in duplicate borders for active tabs and -1px or so for inactive ones.

@patrickhlauke
Copy link
Member

Haven't looked at it too close, but it seems like the outline results in duplicate borders for active tabs and -1px or so for inactive ones.

not sure i'm following what you're seeing. which browser? which example specifically? got a screenshot/pointer to it?

@XhmikosR
Copy link
Member

XhmikosR commented Feb 16, 2021

Sorry, for the late reply. I probably mixed the examples and I was looking at the nav-tabs example, not the nav-pills one.

It works, but the focus style seems to overlap with the other nav-items.

Edit: also browsers seem to have their own focus styles already, and with this patch we will have an inconsistent style in nav-tabs?

@patrickhlauke
Copy link
Member

patrickhlauke commented Feb 16, 2021

Sorry, for the late reply. I probably mixed the examples and I was looking at the nav-tabs example, not the nav-pills one.

It works, but the focus style seems to overlap with the other nav-items.

Yeah I think there's no clean way around this. As that overlapping focus style only shows for keyboard users as they navigate through, and momentarily (before either the link is followed or, in case of dynamic tabs, when that tab then becomes active) it's something I think is not completely deal-breaking (otherwise we have to start moving to inner shadows or something rather that box shadows)

Edit: also browsers seem to have their own focus styles already,

If you go to https://getbootstrap.com/docs/5.0/components/navs-tabs/#pills with Firefox (at least on Windows), there's no visible default focus indication. See this animation where I go back and forth with Tab and note how on the active one nothing can be seen when it gets focus:

firefox-pills-focus

With this change, it's at least consistent across all browsers.

firefox-pills-focus2

Leaving it up to browser default in this case is not a good idea, because of this variability (while yes, Chrome for instance has very clear default focus outline).

and with this patch we will have an inconsistent style in nav-tabs?

You mean inconsistency between the regular .nav, .nav-tabs, and .nav-pills ? yeah, i'd say that can be tackled in a separate PR though? (fwiw in those, the default browser outlines, even while being different across browsers, work ok as they don't disappear for active elements, so this PR tackled specifically the one case where this was an issue, and followed @mdo's suggestion)

@XhmikosR
Copy link
Member

All right, let's wait for @twbs/css-review to have a look. I'd swear there was some kind of CSS property we recently used in another RP .

@patrickhlauke
Copy link
Member

All right, let's wait for @twbs/css-review to have a look. I'd swear there was some kind of CSS property we recently used in another RP .

ah, you might be thinking of https://developer.mozilla.org/en-US/docs/Web/CSS/isolation ... hmm, this may help yes, but not sure how the semi-transparent box shadow over the active pill would show, if at all

@ffoodd
Copy link
Member

ffoodd commented Feb 16, 2021

@XhmikosR @patrickhlauke Just tried, it doesn't help there since our box-shadow is the same color than our background, with a transparency. Either we change this color (and drop transparency, but that sounds inconsistent with other styles) to make it noticeable, or we consider adding space between pills?

There might be other approaches but I'm unable to find one for now.

@XhmikosR
Copy link
Member

I'd vote to just keep it simple and consistent for the time being :)

@patrickhlauke
Copy link
Member

This has slipped a bit off our radar... @mdo and @twbs/css-review in general, what are your feelings on this? it's probably not perfect for all circumstances, but does patch a gap in accessibility we currently have.

Copy link
Member

@ffoodd ffoodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, not perfect but a good patch for now 👌

Focus styles are a whole topic deserving closer attention.

@GeoSot
Copy link
Member

GeoSot commented Aug 29, 2021

@twbs/css-review may we put this on a following project or close it?

@mdo
Copy link
Member

mdo commented Dec 29, 2022

Focus styles coming in #33125.

@mdo mdo closed this Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Accessibility] nav pills tabs : The focus on active link is not visible
7 participants