-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Allow editable to accept aria attributes #3106
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3106 +/- ##
==========================================
+ Coverage 31.64% 31.76% +0.12%
==========================================
Files 217 218 +1
Lines 6282 6302 +20
Branches 1116 1116
==========================================
+ Hits 1988 2002 +14
- Misses 3610 3616 +6
Partials 684 684
Continue to review full report at Codecov.
|
See also #2789, which seems to achieve the same goal with a slightly different implementation (supporting other attributes). |
Ok, I have looked at it and it might be a good solution for non-aria attributes. I'm not sure that I agree that putting aria attributes on the wrong element is a good idea even if you also put aria-hidden; for example quoting from https://www.w3.org/TR/wai-aria/states_and_properties#aria-owns :
One of these two methods needs to be merged or I can not proceed with making auto-completion accessible. |
@afercia what are your thoughts on this? Can there be multiple DOM nodes with |
Hm good question, I'd stick to the specification and not try to do fancy things.
Note that in the W3C specifications, "MUST" has a very mandatory meaning. Software is designed based on specifications. I don't see why screen readers should be so smart to check Screen readers are not browsers, they don't read the DOM directly (that would be too expensive), they just get an ID and point to the targeted element. For example, |
@EphoxJames, based on @aduth's feedback in #2789:
I've pushed ac1d5f7cd0c8fde2032d816a28a9111a1320dead. Quoting from the commit message, "one benefit we now get for free is that the linter is able to warn the author if they pass an invalid ARIA attribute." Feel free to argue with the change. :) |
blocks/editable/tinymce.js
Outdated
const updatedKeys = differenceWith( nextAriaKeys, prevAriaKeys, | ||
( nextKey, prevKey ) => | ||
nextKey === prevKey && | ||
nextProps[ nextKey ] === this.props[ prevKey ] ); |
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 changes seem sensible in general.
My only query is why did you calculate the updated keys using an O(n^2) difference algorithm instead of the O(n) filter that I used originally?
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 wanted to see what this method could look like if we stuck to a single collection interface (difference
/differenceWith
) and whether it made it any clearer, but you're quite right: it's wasteful and doesn't do much for the reader. Amended and pushed.
With this change, Editable expects ARIA attributes to be provided as individual props: `<Editable aria-label="foo" />`. This replaces the approach whereby a single `aria` object prop would be passed. This allows Editable's interface to be kept similar to any native element's interface. One benefit we now get for free is that the linter is able to warn the author if they pass an invalid ARIA attribute: aria-foo: This attribute is an invalid ARIA attribute. (jsx-a11y/aria-props) [eslint]
ac1d5f7
to
700f2a1
Compare
The hand-rolled prop diffing deserves some tests. |
Good idea - I will move the prop diffing into aria.js and add some tests. |
Ok, tests added. Do you think it is good to merge? |
Looks great! |
Description
Previously the TinyMCE component in Editable could only have the aria-label attribute but it is apparent that an accessible implementation of auto-completion and probably other things will require setting additional aria attributes (see #2896 (comment) ) so I have created this small PR to enable passing through any ARIA attribute in the same way that styles are passed.
How Has This Been Tested?
I manually changed autocomplete to pass through the aria-activedescendant which was set to the current autocomplete value and it updated the property on tinymce as the autocomplete selection changed as expected. Tested on Firefox and Chrome.
With the current headless test framework I can't think of a way to automate testing of this but that could be added at a later date when in-browser automated testing becomes available.
Types of changes
New feature.
Checklist: