Add focus handling for "show more" card component
Categories
(Firefox :: Shopping, defect, P3)
Tracking
()
Accessibility Severity | s3 |
People
(Reporter: amy, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
(Keywords: access, Whiteboard: [fidefe-shopping])
There was some excellent accessibility feedback for bug 1842248 here: https://phabricator.services.mozilla.com/D184874#6140327 that this bug is to address.
It's expected that after the user activates Show more with keyboard, the keyboard focus is moved to the top of the new content so a screen reader user would not miss this newly added content. You could add tabindex="-1" to the last visible by default element (it would not be added into the standard focus order but JS would be able to land the focus on it) and, when there is more text added under that last visible content, use the .focus() method to programmatically set focus to that tabindexed element. Otherwise, users of assistive technology would miss that important new information that is added by their request.
Reporter | ||
Updated•2 years ago
|
Updated•2 years ago
|
Comment 1•2 years ago
•
|
||
Thank you for working on it, Amy!
To clarify the expected behavior for after this bug (what is not yet working is marked inline):
-
Keyboard alone:
1.1. User canTab
to theShow more
button and the button has a visible outline when focused with a keyboard
1.2. User can pressEnter
orSpace
to activate theShow more
- the button's visual label changes toShow less
1.3. [To be fixed] After the new content is shown and the button is changed toShow less
, the programmatic focus is moved to the last visible highlight (this element could havetabindex="-1"
so it won't be added to the focus order but would be focusable with.focus()
JS method).
1.4. [To be fixed] User can pressTab
to move the focus toShow less
button
1.5. If the user pressesEnter
orSpace
on theShow less
button, some content is hidden, the button's label is changed toShow more
, and the focus stays on that button (and the focus outline is still visible) -
Screen reader (examples of key shortcuts would be provided for NVDA on Windows):
2.1. User can pressDown arrow
from anywhere (i.e. from theX
Close button on the sidebar) and get to hearSnippets from recent reviews
and its content
2.2. After pressingDown arrow
a couple of times, the user hears the last visible (on-screen) text highlight snippet being announced
2.3. [To be fixed] User pressesDown arrow
once again and they hearShow more, button
(aka they do not hear any text that is not visible on the screen)
2.4. If user pressesEnter
orSpace
while on theShow more
button, the button's visual label changes toShow less
2.5. [To be fixed] After the new content is shown and the button is changed toShow less
, the focus is moved to the last visible highlight and the screen reader user hears the announcement of that highlight.
2.6. A user pressesDown arrow
and hears the next highlight being announced (this highlight was previously hidden)
2.7. A user can pressDown arrow
a few more times to hear the rest of the visible highlights
2.8. From the last highlight, the user pressesDown arrow
once again and they hearShow less, button
2.9. If the user pressesEnter
orSpace
on theShow less
button, the button's label is changed toShow more
, and the focus stays on that button - the user hearsShow more, button
2.10. [To be fixed] If the user pressesUp arrow
fromShow more
button, they would hear the last visible highlight (the last on the screen, not the one that is not visible)
LMK if you have any questions
Updated•2 years ago
|
Comment 2•1 year ago
|
||
Hi Amy, AFAIK, this bug is the one that is supposed to address the off-screen highlights being programmatically hidden as well, correct?
It's been very noticeable while trying to use hover with NVDA and while trying to read all and navigate the sidebar in the browse mode (with Down/Up arrows) - a user would have to listed or arrow through all highlights, basically removing the bonus of having the Show more
button.
Comment 3•1 year ago
|
||
Nominating this bug to the fast follow list (bug 1838699)
Sharing some of my own observations for folks wanting to work on this:
- Currently, we only display the show more button if there are at least 2 highlight categories. Otherwise, if there's only one, we render the basic card
- Plus, we don't set any attribute indicating any clipped snippets (ex.
hidden
,aria-hidden
, etc.), so the screen reader is still capable of reading them if not visible on the card. - In the case of the show more card, it's not always guaranteed that all snippets of the first highlight category will be visible (example), since we set a max height before clipping content.
If we really care about reading what's 100% visible before the "Show more" footer, then we can't rely on just reading the first highlight. One approach I thought of is using an IntersectionObserver to detect which highlights are visible, which would help us:
- know which snippet to set focus on after pressing "Show More"
- know which snippets to set as hidden/not visible
We could potentially set the observer in highlights.mjs to easily reach review-highlights-list
via litElement's this.renderRoot. Another thing to consider is updating each snippet's visibility state whenever we switch between "Show More" and "Show Less".
Updated•8 months ago
|
Description
•