Skip to content

fix(#1231) fix(#1070) A11y: add minimum/maximum labels, use output for displayValue #1148

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

Closed
wants to merge 9 commits into from

Conversation

majornista
Copy link
Collaborator

@majornista majornista commented Oct 6, 2020

Pressing the displayValue should focus the corresponding input.

Closes #1231
Relates to #1070

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issues #1231 and #1070.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

  1. open http://localhost:9003/?path=/story/rangeslider--custom-width
  2. Mouse down on "Label"
  3. Arrow keys should change value of "Minimum" slider thumb
  4. Mouse down on display value text for the "Maximum" slider, to the right of the en dash.
  5. Arrow keys should change value of "Maximum" slider thumb
  6. Mouse down on display value text for the "Minimum" slider, to the left of the en dash.
  7. Arrow keys should change value of "Minimum" slider thumb
  8. Inspect accessibility properties for input within minimum slider thumb.
  9. Accessibility name should be "Label Minimum"
  10. Inspect accessibility properties for input within maximum slider thumb.
  11. Accessibility name should be "Label Maximum"
  12. use mouse to drag Minimum slider on top of Maximum slider, so that they both have the same value
  13. Starting to drag the Minimum slider again, should select the Minimum slider, that was on top last.
  14. use mouse to drag Maximum slider on top of Minimum slider, so that they both have the same value
  15. Starting to drag the Maximum slider again, should select the Maximum slider, that was on top last.

🧢 Your Project:

Copy link
Member

@ktabors ktabors left a comment

Choose a reason for hiding this comment

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

It didn't create an artifact and when I use c3e17c6d951594fa4f4c99312bde4a97d948a6e1 in an existing url it doesn't work.

* governing permissions and limitations under the License.
*/

import csCZ from './cs-CZ.json';
Copy link
Member

Choose a reason for hiding this comment

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

I thought we did import intlMessages from '../intl/*.json'; instead of index.js files?
Is this related to having translation files that aren't in this index.js?

Copy link
Collaborator Author

@majornista majornista Nov 3, 2020

Choose a reason for hiding this comment

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

In this case, I import intlMessages into @react-spectrum/slider/src/SliderBase.tsx at line 15, rather than useSliderThumb, because there doesn't seem to be a way to return the appropriate aria-label for the minimum or maximum thumb from useSliderThumb. Each thumb knows nothing about the other thumbs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've refactored so that the i18n gets added in useSliderThumb.

@devongovett devongovett mentioned this pull request Oct 14, 2020
3 tasks
…layValue

Pressing the displayValue should focus the corresponding input.

fix(adobe#1070) A11y: updates per code review

Co-Authored-By: Robert Snow <[email protected]>
@majornista majornista changed the title fix(#1070) A11y: add minimum/maximum labels, use output for displayValue fix(#1231) fix(#1070) A11y: add minimum/maximum labels, use output for displayValue Nov 4, 2020
Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

I also noticed that the accessibility name (and what was announced by VoiceOver) for the thumbs was "Slider [value of slider]", no "Maximum" or "Minimum" (the aria label was correct though, and aria-labelledby correctly had the input id appended to the end). Confirmed that the rest of what you noted in the repro steps was correct though.

Is this correct? Screenshot below shows the aria-label crossed out in the accessibility dev tool section
image

Otherwise, just some small things/questions

Comment on lines +1 to +4
{
"maximum": "الحد الأقصى",
"minimum": "الحد الأدنى"
}
Copy link
Member

Choose a reason for hiding this comment

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

I presume these translations were vetted by the localization team or came from a prior source that was vetted?

Comment on lines +51 to +57
if (state.values.length === 2 && !ariaLabel) {
if (index === 0) {
ariaLabel = formatMessage('minimum');
} else if (index === 1) {
ariaLabel = formatMessage('maximum');
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps overkill for now, but should this account for cases that have more than 2 slider thumbs? I guess it would just need to check that index === state.value.length - 1 for maximum.

Not sure if it is appropriate though, perhaps these aria messages are for range sliders only

Copy link
Member

Choose a reason for hiding this comment

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

I'm also not sure if we should put this here as it kinda assumes that all two-thumbed sliders are range sliders. IMO the labels should go in Spectrum RangeSlider since we don't have a range specific aria hook.

Comment on lines 26 to 40
div[style='isolation: isolate; color-scheme: dark;'] .label {
color: #b0b0b0;
}

div[style='isolation: isolate; color-scheme: dark;'] .value {
color: #9a9a9a;
}

div[style='isolation: isolate; color-scheme: dark;'] .label {
color: #b0b0b0;
}

div[style='isolation: isolate; color-scheme: dark;'] .value {
color: #9a9a9a;
}
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you have two sets of the same style here

@devongovett
Copy link
Member

I'm going to refactor this slightly and send a separate PR later today. Three issues:

  1. Moving the minimum/maximum labels into React Spectrum's RangeSlider component rather than in useSliderThumb, as it currently makes the assumption that all two-handle sliders represent a range.
  2. Both Slider and RangeSlider support a custom valueLabel, and currently this is not wrapped in an <output> element. Therefore, in the general case, we can't have a separate <output> element for each thumb as we don't know how the value will be formatted. I think having a single <output> element to wrap the entire value label makes sense. This does mean clicking on the individual number values won't focus the corresponding handle but that seems a little hard to discover anyway.
  3. The props for the output element should be returned from useSlider rather than left to each implementation.

@majornista
Copy link
Collaborator Author

I also noticed that the accessibility name (and what was announced by VoiceOver) for the thumbs was "Slider [value of slider]", no "Maximum" or "Minimum" (the aria label was correct though, and aria-labelledby correctly had the input id appended to the end). Confirmed that the rest of what you noted in the repro steps was correct though.

Is this correct? Screenshot below shows the aria-label crossed out in the accessibility dev tool section
image

Otherwise, just some small things/questions

This seems to be a Chromium bug, that I can reproduce: https://codepen.io/majornista/pen/QWKpYrR. Safari seems to be behaving correctly. I can work around it by referencing another element, other than the input, like the handle container element for example, to provide the aria-label for the input.

dannify added a commit that referenced this pull request Dec 18, 2020
…" (#1397)

* Revert "Slider accessibility name calculation fixes for Chrome (#1148) (#1389)"

This reverts commit f8e2bee.

* Update packages/@react-spectrum/color/test/ColorSlider.test.tsx

Co-authored-by: Danni <[email protected]>
majornista pushed a commit to majornista/react-spectrum-v3 that referenced this pull request Dec 18, 2020
…#1148)" (adobe#1397)

* Revert "Slider accessibility name calculation fixes for Chrome (adobe#1148) (adobe#1389)"

This reverts commit f8e2bee.

* Update packages/@react-spectrum/color/test/ColorSlider.test.tsx

Co-authored-by: Danni <[email protected]>
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.

Slider Accessibility Audit
4 participants