-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Expose toggle buttons in accessibility tree #5123
Conversation
I've updated the |
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.
TBC
plugins/button/plugin.js
Outdated
if ( this.isToggle && !this.hasArrow ) { | ||
// Note: aria-pressed attribute should not be added to menuButton instances. (https://dev.ckeditor.com/ticket/11331). | ||
// Do not remove the attribute, set its value (#2444). | ||
element.setAttribute( 'aria-pressed', state === CKEDITOR.TRISTATE_ON ); |
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'm not sure if it's not introducing a breaking change. If someone is already using a button (3rd party plugin) without an arrow, it supports the aria-pressed
feature. Maybe we should instead keep the previous logic for the non-defined isToggle
value?
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.
Actually, we have never supported [aria-pressed]
on menubuttons – the only change I've introduced here is the explicit check if the button is a toggle one.
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 it was setting aria-pressed
for !this.hasArrow
check? Although I don't see it to be working correctly before your changes on VoiceOver despite having aria-pressed="true"
for toggled button - not sure why.
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.
Because toggle buttons are identified by the presence of the [aria-pressed]
attribute. If the attribute is not present, it's considered a normal button. So adding that attribute only for the true
value causes that the button is a toggle one only when it's pressed (in Chrome it isn't at all).
// Toggle button label. | ||
var button = this.uiItems[ 0 ]; | ||
// Only try to change the button if it exists (https://dev.ckeditor.com/ticket/6166) | ||
if ( button ) { | ||
var label = ( this.state == CKEDITOR.TRISTATE_OFF ) ? lang.maximize.maximize : lang.maximize.minimize; | ||
var buttonNode = CKEDITOR.document.getById( button._.id ); | ||
buttonNode.getChild( 1 ).setHtml( label ); | ||
buttonNode.setAttribute( 'title', label ); | ||
buttonNode.setAttribute( 'href', 'javascript:void("' + label + '");' ); // jshint ignore:line | ||
} |
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.
Aren't we losing some information about the second behavior of the button with that change? Previously, this button was nicely labeled with minimize
once maximized. Now, it looks like this change favors screen readers only. Is it possible to keep both an aria-pressed attribute and a label (in the context of accessibility)?
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.
In fact, "Maximize" is the only button that works this way. Every other one does not toggle its label, instead, they apply the correct value of the [aria-pressed]
attribute.
Additionally, I do not think that the information is lost. The fact that the editor is maximized is communicated via two things: maximized editor (obviously) and the styling of the pressed button. It's analogous to other toggle buttons, e.g. "Bold" – we have a pressed "Bold" button, not a pressed "Unbold" button.
And a small nitpick – I really think that "MInimize" means something slightly different than restoring the maximized window to its original size 😛
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.
Yeah, I think that makes sense, thanks for the explanation 👍🏻
I've removed the unnecessary template for the |
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.
These changes look good but I was only able to do manual tests using VoiceOver as my VM machines decided to not support OS sounds. @sculpt0r could you give it a try and confirm that manual test for screen readers works correctly on JAWS + Firefox and NVDA?
There is one issue but I'm not sure if it's related to your changes. Toggling source area forces the screen reader (VoiceOver) to read some garbage about being inside a table (for manual test with a table) or inside a list (for nightly sample). I'm not sure, but it looks like screen reader focus goes somewhere else after toggling a button?
plugins/button/plugin.js
Outdated
if ( this.isToggle && !this.hasArrow ) { | ||
// Note: aria-pressed attribute should not be added to menuButton instances. (https://dev.ckeditor.com/ticket/11331). | ||
// Do not remove the attribute, set its value (#2444). | ||
element.setAttribute( 'aria-pressed', state === CKEDITOR.TRISTATE_ON ); |
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 it was setting aria-pressed
for !this.hasArrow
check? Although I don't see it to be working correctly before your changes on VoiceOver despite having aria-pressed="true"
for toggled button - not sure why.
That's weird 🤔 The focus does not go anywhere, it stays on the button. The issue you describe appears only in Chrome, I can't reproduce it in Firefox or Safari. It looks like a browser bug. |
I've fixed the reported codestyle issues. |
Co-authored-by: Jacek Bogdański <jacekbogd@gmail.com>
Rebased onto the newest master |
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.
@Comandeer nice work with the test tooling 👍
JAWS & NVDA works fine 🎉 I have only doubts about naming and other small stuff in a few places - please take a look at the inline comments.
Additionally - I think we should add a test with the language button in the toolbar. It is not the plain toggle button, but the code around hasArrow
was changed and it will be good to verify whenever this button still works as we expected - also with screen readers.
Co-authored-by: Bartłomiej Kalemba <b.kalemba@cksource.com>
Co-authored-by: Bartłomiej Kalemba <b.kalemba@cksource.com>
Ok, I've refactored names a bit and added a manual test for screen readers and menu 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.
LGTM 🎉
Thank you for the separated test for the menu button. Thanks to that, I found and extracted an issue with aria-expanded
: #5144
Added a changelog.
@Comandeer - we have to wait for @jacekbogdanski approval - since he also reviewed this PR. Without it, GH is blocking me with the merge. |
It's been a while since we last heard from you. We are marking this pull request as stale due to inactivity. Please provide the requested feedback or the pull request will be closed after next 7 days. |
New features: | ||
|
||
* [#2444](https://github.com/ckeditor/ckeditor4/issues/2444): Togglable toolbar buttons are now exposed as toggle buttons in the browser's accessibility tree. |
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.
A feature changelog entry should go to a major release.
What is the purpose of this pull request?
New feature
Does your PR contain necessary tests?
All patches that change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
Did you follow the CKEditor 4 code style guide?
Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.
What is the proposed changelog entry for this pull request?
What changes did you make?
I've changed the way of handling the
[aria-pressed]
attribute in thebutton
plugin. After the changes, the attribute is always present on the button and only its value is changed (previously the attribute was removed when the button was not pressed). Additionally, I've added theisToggle
option to the button's definition which indicates that the button is togglable (this option is needed to handle the initial state of the toggle buttons).I've then added
isToogle
option to plugins using toggle buttons:However, there are still some plugins that require additional attention:
[aria-pressed]
attribute, it changes the label of the button (from "Maximize" to "Minimize"; I'd suggest replacing the current method with the[aria-pressed]
one, used in other plugins.Which issues does your PR resolve?
Closes #2444.
Closes #4543.