-
Notifications
You must be signed in to change notification settings - Fork 361
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
Updated thermostat slider example (slider-2) #1706
Conversation
… high contrast compatibility
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.
disregard - mistakenly chose approve
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 Windows 10, NVDA 2020.3, JAWS 2020.2012.13; Firefox 84.0.1 and Chrome 87.0.4280.141. All worked as expected as far as documented accessibility functionality, keyboard interaction, and screen readers were concerned.
High contrast was mostly good, but the label on the thumb itself did not show up with HCM Black and Firefox. @carmacleod, could I tag you in for MacOS a11y tests? My test Mac is with another co-worker at the moment.
@charmarkk |
Good to know! The colors are bit dark in HCM Black with Edge, but the text does show up. You're quite welcome! I'll mention this on #1704 and, once we verify all is working well with MacOS I'll update my review. |
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.
The rects for the rails need to have aria-hidden="true" to hide the rect from screen readers. For example, VO in iOS navigates to the rail rect and says "sky-blue image" - which is confusing.
Degrees | ||
</div> | ||
<svg class="slider-group" width="140" height="340"> | ||
<rect class="rail" x="60" y="20" width="6" height="300" rx="5"/> |
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.
<rect class="rail" x="60" y="20" width="6" height="300" rx="5"/> | |
<rect class="rail" x="60" y="20" width="6" height="300" rx="5" aria-hidden="true"/> |
<div class="slider-thermostat-text"> | ||
<div id="id-hc-label" class="label">Heat/Cool</div> | ||
<svg class="slider-group" width="210" height="85"> | ||
<rect class="rail" x="25" y="25" width="92" height="6" rx="5"/> |
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.
<rect class="rail" x="25" y="25" width="92" height="6" rx="5"/> | |
<rect class="rail" x="25" y="25" width="92" height="6" rx="5" aria-hidden="true"/> |
<div class="slider-thermostat-text"> | ||
<div id="id-fan-label" class="label">Fan</div> | ||
<svg class="slider-group" width="210" height="85"> | ||
<rect class="rail" x="25" y="25" width="132" height="6" rx="5"/> |
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.
<rect class="rail" x="25" y="25" width="132" height="6" rx="5"/> | |
<rect class="rail" x="25" y="25" width="132" height="6" rx="5" aria-hidden="true"/> |
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.
The reason the label on the thumb is not showing up in the currentColor is that SVG text elements use fill, not color, for drawing text.
Regarding SVG and high contrast support: The dark grey I'm not quite sure how to fix this without using If we don't use the forced-colors media query, then I think (?) the only color choice we have is currentColor? but that wouldn't help fully because we need more than one color. I could be missing something, though. |
@carmacleod One color would be enough in my opinion. Alternatively, the graphic can have an outline that has sufficient contrast to the content. Then the graphic would be well visible with any background color |
The slider's contrast ratio of about 1.5:1 in the normal view (without Windows HCM) is clearly below the minimum contrast. This applies to the line in the focused and unfocused state. Only the handle is clearly visible. However, the handle alone is not sufficient to recognize the element as a slider. |
Good point, @JAWS-test - both the light grey #cccccc and the light blue #adddff rail colors fail 3:1 non-text contrast against white. So we need some darker colors for the rail.
Maybe. But I'm not sure if having the thumb and rail be the same color makes sense (for one thing, they would fail 3:1 non-text contrast against each other). For example, if we use currentColor for both thumb and rail then both thumb and rail are white in HCM Black, and I don't think it's clear what this component is and what it does: Similarly, in HCM White and even in normal mode if we use currentColor, then both thumb and rail would be black. I thought it might be clearer to use: @media (forced-colors: active) {
.thumb {fill: Highlight}
} Which gives a cyan blue thumb on a white rail, which looks like this in HCM Dark: Although... argh! The white and cyan still fail 3:1 non-text contrast against each other, because they only have contrast of 1.5:1. And I haven't even looked at focus states. :( Colors are hard! 😢 |
I don't see a problem there. In Firefox, sliders with Furthermore, I think it makes more sense that in HCM interactive elements are recognizable as such, i.e. for links the set link color is used and for form elements the color for them (in my screenshots: white) and not the color for text (yellow). If the text color is used, it is not recognizable that it is an interactive element. Then it could simply be a display element (without the possibility of operation), e.g. the |
In HCM, the browser does not choose its own colors. It adopts the Windows colors for all elements. The color green in the screenshot is the Windows green for selected text (I think it is the system color |
Ah, ok. But you must have changed your selected color to green, which confused me - I thought it was the browser. 😄 Which is why I thought it might be clearer to use: @media (forced-colors: active) {
.thumb {fill: Highlight}
} Or even just (if we don't care what color the thumb has in "normal" mode): .thumb {fill: Highlight} |
No, this is the default color in HCM mode number 1 (see screenshot). I have not changed anything. Maybe Microsoft has country specific colors...?
I think |
@carmacleod
Reviews on the updates are welcome. |
@jongund |
However, I have discovered a problem regarding the keyboard operation. When the slider receives the keyboard focus, the slider does not scroll completely into the visible area. Scrolling is also not possible with the arrow keys, as arrow keys are used to operate the slider. Thus, the slider may not be visible to keyboard users. The problem is more severe in Firefox than in Chrome. In Firefox, the slider may be barely visible. In Chrome, the slider is always visible, but not its values ("Off", "Low", "High" etc.). |
JAWS and NVDA (with Chrome) output around the sliders unlabeled graphics. The sliders themselves are also output as graphics. This is because the slider is inside the SVG graphic. It would probably be better to mark the graphic as a layout graphic or to place role=slider outside the SVG and mark the SVG with aria-hidden=true |
@JAWS-test Regarding:
I don't understand the first sentence - can you explain more?
Good point re scrolling. Regarding colors on focus, there is still one contrast problem, which is that |
The SVG is recognized as a graphic. Inside the graphic is the slider. |
The fact that the slider is in a graphic causes another problem with JAWS (not with NVDA): The current value of the slider is not output by JAWS when reading with the arrow keys or with quick navigation (F). The problem does not occur if the slider is not inside a graphic (see https://w3c.github.io/aria-practices/examples/slider/slider-2.html) |
An ARIA slider without a button or spin button cannot be operated with AT on a touch device. Therefore, it is very good that the examples contain buttons or a spin button to enable operation on touch devices. However, I am considering whether it is sufficiently clear with the screen reader that slider and button/spin button are related, i.e. operation of one causes the changing the value of the other. aria-controls is currently used, but is deliberately no longer output by JAWS, for example. On a mobile device, I first reach the slider, which I cannot operate, and then the buttons. Wouldn't it make sense to have either the buttons in the reading order before the slider, or at the slider a hint about the buttons? And would it perhaps make sense to mark the selected button with aria-pressed=true? |
Regarding mobile support, I don't think we should even try to implement a touch-based slider without increment/decrement events. I don't think we're helping anybody by trying to work around the missing API. I think we need to copy the warning note from the slider pattern to the top of the slider example pages, and add something like: "If you need a slider that works on mobile, use an HTML range input.", i.e. basically what @ZoeBijl suggested in #8 (comment). Note that authors can style range inputs quite extensively these days, including rotating them into vertical orientation, etc. The problem with trying to work around the missing mobile/touch gesture events is that:
I don't know of a way to make an aria slider work nicely on touch/mobile, but I haven't developed for those platforms, so maybe I am missing something. |
@JAWS-test I somehow missed seeing your mobile comment until after I saved mine. :) If the group decides to try to create a mobile aria slider, I agree that we need to make those relationships clearer somehow. I think we would also need to split this example into 2: one for desktop/keyboard and one for mobile/touch.
Yes, or maybe even use radios. :) |
incidentally, i recently had some downtime over the holidays to revisit some other patterns and their shortcomings on touch. it's ... not a pretty picture overall. some of the fundamental "expose things like they were native elements and intercept/react to the standard keyboard keys to interact with them" approaches simply fall apart on non-keyboard + AT scenarios #8 (comment) |
ouch.
agreed. have added "agenda" label to this pr. |
I looked into how component libraries make sliders work on touch/mobile. Apparently they use an HTML range input but hide it visually, and use other elements as visual stand-ins. Here's an example react-aria slider that works on my iPhone (with and without VO). It uses pointer events for the tapping and dragging, and the hidden range input for focus and screen reader interaction. I'm not sure whether this type of thing belongs in the APG or not, but I'm leaning towards "not".
Interestingly, even though the documentation for the react-aria slider says:
... all browsers I tested the highly styled vertical and horizontal sliders in rendered them correctly. That includes Chrome, Edge, Firefox, Safari, mobile Safari, and even IE11. (The only thing IE11 didn't support was PageUp and PageDown). So I wonder how far back in browser-versions you have to go to have styling difficulties. |
yes, for sliders, that's pretty much the conclusion I think many came to a few years ago - either have a hidden an interesting example i saw using the hidden |
@patrickhlauke @carmacleod |
I think they would just think that the example is broken on mobile, because the slider is there but it doesn't work. We may be able to make the dragging work for sighted touch users by using pointer events, but I'm not 100% sure of that, because I haven't developed for mobile. If we can at least make it work properly for sighted touch users, then we could maybe hide the slider for mobile screen reader users so that it doesn't cause confusion. We could even consider using a hidden range input instead of a visible number input, just to make it more of a "slider example". :) [Edit: Actually, apparently you can't tell if you're running on a touch device, so never mind hiding the broken slider for screen reader users on touch devices...] Even if we get it to work a bit more, I still think a warning note may be more useful to designers and developers.
Zoe used the styling and placement shown below. The warning text is displayed in a red box right after the Example heading on the relevant example page. (Actually, now that we have the CodePen button, it would go after that.) We can work on the words, but I think the fairest thing to authors is an explicit heads-up. |
I mean I'm almost thinking that the whole pattern itself may be in jeopardy. As the line between touch and non-touch devices, with AT, is blurring, you'll find more instances where the official pattern simply isn't fit for purpose? Don't know, maybe I'm being too overzealous here, but perhaps it should be slightly rethought, salvage what can be salvaged (e.g. suggesting complementing an actual |
I don't think we need to quash the pattern, but it is waiting on as-yet-unspecified AOM events to make it viable on mobile. Screen readers need to be able to say, e.g., "swipe up or down with one finger to adjust the value" and then take those gestures and turn them into events that the component can listen for. Current thinking is "increment" and "decrement" for the events.
I think we can warn about this in the APG, and create examples for the APG Redesign. |
@patrickhlauke |
@JAWS-test Jon |
@jongund Thank you very much for the invitation. Unfortunately, since I do not speak English, I cannot attend. I wish good luck with the further development of the example |
This pull request is no longer needed due to pull #1755. |
I have updated the thermostat slider example using the vertical slider and two text sliders:
Preview slider thermostat example
Review checklist