Problem/Motivation
Seeing this both in Webform tests on next minor and our own tests.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork webform-3563385
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
berdirLooks like this happens because the referenced core issue has been fixed. I explicitly went with a version check here, because that will make it easier to remove this block once webform requires 11.3 at some point in the future.
Comment #4
liam morlandWhy is it comparing against 11.2.99? Is that supposed to be 11.2.9?
Comment #5
berdir11.3-rc2 (which is the current 11.3 release) as well as 11.3.x-dev are considered to be lower than 11.3.0, so I'm using 11.2.99 (which will pretty much guaranteed never exist) as a version check: https://3v4l.org/onI8I
Comment #6
liam morlandThis code doesn't make any sense to me. Am I misreading it? The only substantive thing that it does is run an
unset(). That only happens if$element['#attributes']['aria-describedby']is not empty,$element[$key]['#attributes']['aria-describedby']is empty, and these two things are===to each other. That can never happen anyway.This code was added in commit ed5fc4a for #2983248: [accessibility] Improve element, details, and fieldset description handling.
Comment #7
berdirYeah, your assessment sounds valid. I suspect the empty check on $element[$key]['#attributes']['aria-describedby'] should have been a !empty(), to prevent the error that we're running into now with 11.3.
I was first going to suggest to just remove the whole thing, but actually, I think it makes sense to fix the logic. Because as I suspected, WebformElementCompositeTest is an explicit test for this described-by logic and currently asserts the wrong result because it's not being fixed.
Instead of having to another add version check in the test and asserting different output, I changed the empty() to !empty(), changed the version check there to a @todo. This should now pass on all core versions.
Comment #8
liam morlandWith your change, this removes
aria-describedbyfrom the child elements if it is the same as thearia-describedbyon the parent element. That makes sense as a thing to do, but I don't see how it fits with the comment which is aboutaria-describedbythe refers to not existing element ID. It only removes if it points to the same thing that the parent still points to. Still this appears to be an improvement and I'm inclined to merge it.Comment #9
berdirI think I don't understand your comment.
The result of my change is that it results in the same behavior in 11.2 and earlier as core now produces by default in 11.3+. I believe that was always the intent of this code, which is why it referenced the core issue. The test change also passes on 11.3 when the code is removed, and eventually when you require ^11.3, you can drop it.
Comment #10
liam morlandThe existing comment says "Some aria-describedby refers to not existing element ID." The code could unset
$element[$key]['#attributes']['aria-describedby']but only if that is the same as$element['#attributes']['aria-describedby']. So, if the former is referring to a "not existing element ID", then the latter will still refer to it. This code will not remove the reference to a "not existing element ID".Comment #11
berdirThat comment is not an explanation of what the code does, it's the title of that core issue back in 2018 which has been changed in comment #9 there: #2839344-9: Broken aria-describedby in radios and checkboxes
Comment #12
vladimirausThank you for your contributions. 🍻
Applied and tested in D11.3.
The warning disappeared.
Comment #13
liam morlandSomething is not right with the test. The comment says "Check radios 'aria-describedby' with wrapper description." but with this chanage there is no test at all for
aria-describedby.Comment #14
liam morlandComment #17
liam morland