Problem/Motivation
In order to validate pages for W3C standards, we need to fix aria validation issues on collapsible fieldsets.
Right now, when fieldset is rendered with duplicated aria-expanded attribut without it's value.
Example taken from /admin/appearance page :
Line 161, Column 150: Duplicate attribute aria-expanded.
…min-theme" aria-expanded aria-expanded>Administration theme</summary><div clas…
Line 161, Column 150: Bad value for attribute aria-expanded on element summary.
…min-theme" aria-expanded aria-expanded>Administration theme</summary><div clas…
While according to aria document (http://www.w3.org/TR/html-aria/) it should be : aria-expanded="true" or aria-expanded="false", see: http://www.w3.org/TR/wai-aria-1.1/#aria-expanded
Proposed resolution
- Remove one aria-expanded
- Render the aria-expanded to true / false.
Remaining tasks
- Write failing test
- Remove one of the aria-expanded
- Render properly the aria-expanded
User interface changes
- none
API changes
- none
Beta phase evaluation
Issue category | Bug because correct markup and aria is expected |
---|---|
Issue priority | Normal because it does not break anything but screen-reader accessibility. |
Unfrozen changes | Unfrozen because it only changes markup and adds a JS file in the collapse library, but nothing disruptive. |
Prioritized changes | The main goal of this issue is accessibility and standarization of markup. |
Comment | File | Size | Author |
---|---|---|---|
#50 | collapsed-admin-theme.png | 91.98 KB | mgifford |
#50 | expanded-admin-theme.png | 108.08 KB | mgifford |
#47 | interdiff.txt | 843 bytes | Dom. |
#47 | core-js-aria-details-2472177-47.patch | 2.54 KB | Dom. |
#45 | interdiff.txt | 1.79 KB | nod_ |
Comments
Comment #1
nod_Comment #2
Dom. CreditAttribution: Dom. commentedComment #3
drubbHere's a first patch for this
Comment #4
Dom. CreditAttribution: Dom. commentedHi,
Nice work : this solve the point to add open/close value depending on whether the attribut "open" is present at rendering time.
It nows needs further work to :
- toogle from open/close value depending on action (using JS)
- remove the duplicate of aria-expanded in source code
Comment #5
drubbThis second patch should fix the duplication issue, too. Regarding the JavaScript thing, I've no idea about the right place for the necessary additions. I had a look at collapse.js, but this file doesn't seem to be involved.
Comment #6
dimaro CreditAttribution: dimaro at La Drupalera by Emergya commentedCheck as Need review to run tests.
Comment #7
drubbComment #8
Dom. CreditAttribution: Dom. commented@drubb for #5: +1 for this ! The patch does not apply anymore but applying manually and testing it removes duplicate indeed. Let's find out the JS thing now and we will merge the three sub-patches to one then.
Comment #9
drubb@dom patch #2 includes patch #1! Not sure if this is best practice?
Comment #10
drubbInfo for the JS part: the surrounding div has an attribute 'open'. It gets toggled even when js is disabled. If we find the place where this magic happens, we're almost done.
Comment #11
Dom. CreditAttribution: Dom. commentedHere is a patch for the JS in collapse.js It actually works for Firefox for instance where Modernizr does do the job. On Chrome, it won't work because of :
Thus I would like @nod_ opinion on this :
- run the if(Modernizr...) after CollapsibleDetails runs, so that we can run setupSummary and have this.$legend accessible in the if(Modernizr)
- split toogle() method into two parts : what is about open that can be run by Modernizr, what is about arias
- call the aria part of toggle before the return statement in the if(Modernizr)
I guess that would make the trick. Would it be clean way however is up to @nod_.
Comment #12
drubbAh, that's why I didn't get it. I've used Chrome :-)
Comment #13
nod_We need a separate js file for that, we can remove all the aria stuff from the fallback script and handle that for both native and polyfilled in a new file (that file can be added to the same library, just needs to be in a different file).
Comment #14
Dom. CreditAttribution: Dom. commentedOK, either me or @drubb that seems interested will try a proposal and we will come back for RTBC.
Thanks a lot for advice meanwhile !
Comment #15
drubb@dom It's up to you, I have no idea about this modernizr stuff, sorry!
Comment #16
Dom. CreditAttribution: Dom. commentedHum.. Could we have discussion on this ? Two questions :
- why adding arias in a new file for this, while it is not for other things ?
For instance arias are everywhere at : progress.js, states.js, tablegrad.js, basically every elements actually. Moving arias from collapse.js to aria.js for instance, we need to refactor everything to use the same aira file I guess, should not we ?
- in the case aria for collapse.js is in another folder. Does it need to be self-dependent, so also find the details elements and stuff or should it be called from the current js (thus injected), just like Modernizr is ?
Comment #17
nod_Talked this through, Dom. is working on it.
Comment #18
Dom. CreditAttribution: Dom. commentedComment #19
Dom. CreditAttribution: Dom. commentedFinally here is a final patch for the whole issue to be reviewed.
Comment #20
Dom. CreditAttribution: Dom. commentedComment #21
nod_Missing the actual aria js file.
Comment #22
Dom. CreditAttribution: Dom. commentedOh sh** ! Here it is !
Comment #23
Dom. CreditAttribution: Dom. commentedComment #25
nod_to make it easier to read I'd prefer
detailsAria
This is missing the
.once('detailsAria')
after the find.I'd rather use event delegation on body, something like
$('body').once('detailsAria').on('click.detailsAria', 'summary', function () {});
Since listening to clicks on summary is more direct we can do something like
var parent = event.currentTarget.parentNode;
I don't think we need to add anything to
this
to make it work.On firefox this doesn't work so well, probably a event listener thing. Works fine in chrome.
Comment #26
Dom. CreditAttribution: Dom. commentedI have done all modifications but before link patch I still have something to resolve :
- chrome applies the open attribute after the JS. Thus when you have details close and you open it, open attribut is not yet there in the onClick method.
- firefox is polyfilled, and this polyfill happends before. Thus when you have details close and you open it, the open attribut is there yet on the onClick method.
Thus my isOpen value is reversed depending on Chrome or Firefox, and the behavior is then upside/down. Do you know how to order the JS in the assets ? Can I have the details-aria behavior running before the collapse.js polyfill so it could be the same behavior as per Chrome ? Maybe in .libraries.yml ?
I tried this but has no chances :
Comment #27
nod_We really don't want to use weights. Thanks for finding out the root issue with FF/chrome. Feel free to upload the patch you have now even if it doesn't solve everything :)
I'll look into that last issue when I can.
Comment #28
Dom. CreditAttribution: Dom. commentedHere is a patch that works for both Chrome and Firefox (without using weights). It add the corrections from #25 except does not make use of event.currentTarget but uses $(this) as per the exemple of on() in jQuery documentation.
Comment #29
nod_We have eslint errors:
About the code, I'd still like to use event delegation because of performance. On the module page (which has a lot of details element) we go from 6ms to 1ms for init.
Here is an updated patch. It solves the issue with firefox and chrome too. It's not really novice after all so I'm removing that :)
Comment #31
nod_better with the new file…
Comment #32
Dom. CreditAttribution: Dom. commentedHi !
This is reviewed : I diffed it with #28 to understand the difference, tested with both Chrome and Firefox and finally check with W3C validator for the result.
RTBC+1 for me
If I could split hair, I would just add that the comment needs a full sentence with a point but that's okay !
// We're basing the value of
Comment #33
Dom. CreditAttribution: Dom. commentedAdd beta-phase description.
Comment #34
alexpottHalf a sentence
Comment #35
mgiffordShould it be this:
I think that's what's happening. Thanks for catching the half sentence.
Comment #36
Cliff CreditAttribution: Cliff as a volunteer commentedUpdating tags to indicate that this is a feature to improve accessibility and that the issue needs accessibility review.
Comment #37
nod_Yup, sorry about that, fixed the comment.
Comment #39
nod_Again, forgot the new file.
Comment #40
nod_Comment #43
mgiffordI've tested this and it looks ready to be RTBC again. It's much more descriptive now.
Comment #44
alexpottIt feels weird to call a function setAriaAttr() when in gets an attribute. Also we appear to call this method twice for little reason.
Comment #45
nod_You're right, missed the big picture.
Comment #46
Dom. CreditAttribution: Dom. commentedHi !
In patch #45, aria-pressed correction have been forgotten (regarding patch #37). Thus, it does not validate W3C anymore. However alex.pott #44 has been corrected.
Comment #47
Dom. CreditAttribution: Dom. commentedNew patch with correction for aria-pressed added by compared to #45.
Comment #50
mgifford@Dom. you should get the same result with @nod_'s code as
$variables['summary_attributes']['aria-pressed'] = $variables['summary_attributes']['aria-expanded'];
and you're using the same logic in the line above. I think the patch in #45 would just be more efficient. The end result in both looks like this from what I can tell:Comment #51
Dom. CreditAttribution: Dom. commentedHi!
Sorry, I retested patch #45 and it works fine actually !
@mgifford: indeed #45 is better, I just... don't know why I saw it wrong the first time.
@nod_: sorry for I did not tested properly #45 in the first place.
The reviewed patch is #45, not the following.
Comment #52
alexpottCommitted the patch in #45. 98cddda and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.