Repository navigation
fix(ui5-input): expose clear icon as a button with an accessible name - #14281
Open
devteamaegis wants to merge 1 commit into
Open
devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
The clear icon wrapper had no role or label, and the inner ui5-icon is rendered in its default Decorative mode, which sets aria-hidden="true". The existing "Clear" accessible name on the icon was therefore never exposed, so assistive technologies saw an unlabelled clickable element. Add role="button" and aria-label to the clear icon wrapper, reusing the existing INPUT_CLEAR_ICON_ACC_NAME text. Focus behaviour is unchanged (the wrapper stays tabindex="-1"). Fixes UI5#14265 Signed-off-by: devteamaegis <devteam.aegis@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14265
Problem
With
showClearIconset, the clear icon inui5-inputhas no accessible name. The wrapperdivthat handles the click has no role or label. The innerui5-icondoes getaccessibleName="Clear", but it renders in its defaultDecorativemode. In that mode the icon's root getsaria-hidden="true"androle="presentation", so the name never reaches assistive technology.Change
InputTemplate.tsx: addrole="button"andaria-label={this.clearIconAccessibleName}to.ui5-input-clear-icon-wrapper. This reuses the existingINPUT_CLEAR_ICON_ACC_NAME("Clear") text, so no new i18n keys are needed. That matches the two spec points quoted in the issue:role=buttonon inner button-like icons, and anaria-labelfor icon-only buttons.tabindex="-1", so the clear icon stays out of the tab order as it is today.Input.cy.tsx: new test that checks the wrapper hasrole="button"andaria-label="Clear".I set the role on the wrapper rather than switching the icon to
mode="Interactive". Interactive mode would puttabindex="0"and key handlers on the inner SVG, which would change focus behaviour.ui5-combobox,ui5-multi-comboboxand the AIui5-inputuse the same clear-icon markup and have the same gap. I kept this PR to the component in the issue. I can extend it to those if you'd like.Testing
yarn tspasses,packages/mainyarn lintpasses, and the compileddist/InputTemplate.jscontains the new attributes.This was investigated and written with an AI coding agent (Claude) working on my behalf.