-
Notifications
You must be signed in to change notification settings - Fork 144
Rework advanced filters screen reader text generation #1099
Conversation
9fa1d5f
to
579968b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good @jeffstieler !
I noted a couple small things and a comment on unread screenReaderText
.
import { textContent } from '../utils'; | ||
|
||
describe( 'textContent()', () => { | ||
test( 'should be got text `Hello World`', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be got text
=> should get text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, copy pasta'd from https://github.com/rwu823/react-addons-text-content/blob/master/test/react-addons-text-content.spec.js#L5.
I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9ce4d9e.
onChange={ onChange } | ||
/> | ||
: <TextControlWithAffixes | ||
prefix={ <span dangerouslySetInnerHTML={ { __html: currencySymbol } } /> } | ||
className="woocommerce-filters-advanced__input" | ||
type="number" | ||
value={ value } | ||
aria-label={ label } | ||
onChange={ onChange } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you can add a prop min="0"
to prevent negative numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's handle this in a separate PR - the NumberFilter
component doesn't have any sort of input validation yet.
<span className="screen-reader-text"> | ||
{ screenReaderText } | ||
</span> | ||
) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Chrome and VoiceOver, this screenReaderText
never gets read. I see it appropriately added to the DOM when the sentence is complete, however.
Sorry if this has been previously discussed, but would it not make sense to add screenReaderText
to the legend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not read even when you move to it?
It's not meant to be automatically read, as that interrupts the content entry - having it in legend is too noisy, and why @jeffstieler is doing all this work 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't be tabbed to, but if you use the VO controls you'll navigate to it after the last filter input, before the remove button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but if you use the VO controls you'll navigate to it after the last filter input
via tabbing? Or is there another method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I figured out how to navigate to the text using VO controls. I'm not a VO power user (yet), so forgive my novice comment, but I'm not experiencing the input being too noisy on master -- the legend only gets read when the fieldset has focus.
I assumed VO users would tab their way through a form, instead of using the arrow controls to read text in a span, and by doing so skip right over the text being added in this PR. Is this assumption wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed VO users would tab their way through a form, instead of using the arrow controls to read text in a span, and by doing so skip right over the text being added in this PR. Is this assumption wrong?
I'm not knowledgeable enough to say - I'm new to a11y 🙂. I defer to @ryelle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this assumption wrong?
It's over-simplifying, not exactly wrong – screen reader users will tab to move through interactive components (forms, buttons, etc), but they'll use the arrow nav to move through the page's full contents (otherwise they'd never read non-interactive page content). They might also use other navigation methods (skipping through headings, or a list of links, or a list of buttons, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, I don't know what a real user would do in this scenario - but this approach is better than interrupting the user while they're typing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thank you for the clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with VoiceOver + Safari, and it's working as expected. I'm not exactly sure why we need textContent
, though, can you explain that a little more?
I initially introduced that so we'd be passing a string to |
In testing, removing <span class="screen-reader-text">Item Quantity is <span>Less Than</span> <span>1</span></span> Which VoiceOver requires several interactions to completely read - 3 in total for this example. Using Edit: even using |
Only describe full filter if all values are set. Describe each input more precisely. Based on conversation here: #1089 (comment)
…bel from accessibility tree.
…criptive span for screen reader instead of using speak().
9ce4d9e
to
079ff48
Compare
@jeffstieler That confused me a little because spans are not supposed to create breaks like that. This seems to be a Safari vs Chrome difference - Safari + VO doesn't break the nested spans apart, but Chrome + VO does. If you switch the wrapper (the element with <div class="screen-reader-text">Item Quantity is <span>Less Than</span> <span>1</span></div> |
@ryelle it seems that VO (even in Safari) doesn't cope well with line breaks in the HTML. In my testing (on this PR) using an outer Here's a screen capture: https://cloudup.com/c_Ne8_uyoj3 (you can see the selected VO element, the VO overlay screen, and the markup of the I'll look in/around the |
Hm, even with linebreaks in a plain HTML page, VoiceOver reads it as one line for me
can you push up your latest changes so I can test it out myself? |
Perhaps then I'm not navigating correctly? I'm using Pushed up my changes - 2532539. |
I figured it out – the wp core CSS for Edit: You should try out using the class |
@ryelle (Following up on a Slack convo we had) Changing to the Even while resetting the I don't believe any of these issues were present with the |
2532539
to
079ff48
Compare
Tested with the (formerly) previous commit - everything is fine there. I've deleted the commit that removed the usage of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reading correctly now, no pauses/broken sentences. Thanks for all your work on this!
Based on conversation here: #1089 (comment)
This PR seeks to:
Notes:
There is an opportunity to DRY up the markup in the render of
NumberFilter
,SearchFilter
, andSelectFilter
, but I've left that undone as it might be a premature optimization. I can certainly turn that into another component if we decide that's cleanup worth doing.Also, this PR adds a utility method called
textContent()
. It's essentiallyreact-addons-text-content
- I made the decision to just copy pasta the code into our project since the dependency is rather small and hasn't been updated in 3 years.To test:
<legend>
for each doesn't change when interacting the the component<div>
with classscreen-reader-text
is rendered only when all of the filter inputs have values