Repository navigation
fix(ui5-li): do not set aria-selected on role listitem (#14235) - #14245
amirthn6533 wants to merge 1 commit into
Conversation
|
|
|
Hello @UI5/ui5-team-ctr-rod, Could you please take a look at this PR? |
TeodorTaushanov
left a comment
There was a problem hiding this comment.
If aria-selected needs to be removed, the change should be made in ListItem, since UploadCollectionItem inherits this behavior from it.
Signed-off-by: Amir Tahani <amirthn653381@gmail.com>
d51544f to
99f3c6e
Compare
|
Hello @TeodorTaushanov, Thank you for the review and guidance! You are completely right — I have updated the PR accordingly:
Could you please take another look when you have a moment? Thanks again! |
PR checklist
Background & Description
In
ListItem(and derived components likeUploadCollectionItem), the root<li>renders withrole="listitem"by default. Under the W3C WAI-ARIA specification,aria-selectedis strictly permitted only on the following roles:gridcell,option,row,tab,columnheader,rowheader, andtreeitem.Applying
aria-selected(e.g.aria-selected="false"oraria-selected="true") to an element withrole="listitem"violates WAI-ARIA and triggers automated accessibility failures (e.g. axe-core rulearia-allowed-attrand AccessContinuum test 264).Selection state for
listitemelements is already communicated accessibly via:ariaSelectedText("Selected" / "Not Selected") announced inaria-describedbyui5-checkboxwitharia-checkedinMultiplemode, andui5-radio-buttonin single selection mode)When
ListItemis configured withrole="option"(e.g. in aListBoxcontainer) orrole="treeitem",aria-selectedis valid and remains properly exposed.Changes
packages/main/src/ListItem.ts: Conditionally exposeariaSelectedin_accInfoonly when the item's accessible role supports it (optionortreeitem), preventing invalidaria-selectedattributes from rendering onrole="listitem".packages/main/cypress/specs/List.cy.tsxvalidating that:role="listitem"do not renderaria-selected.role="option"(underaccessibleRole="ListBox") correctly renderaria-selected.packages/fiori/cypress/specs/UploadCollection.cy.tsxasserting thatUploadCollectionItemretainsrole="listitem"without renderingaria-selected.packages/fiori/cypress/specs/UserSettingsDialog.cy.tsxfor items withrole="listitem".Fixes: #14235