Skip to content

Commit 39f8e66

Browse files
authored
fix(ui5-select): aria-controls attr added (#12050)
Fixes: #12018
1 parent 191b700 commit 39f8e66

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

packages/main/cypress/specs/Select.cy.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,27 @@ describe("Select - Accessibility", () => {
224224
.find(".ui5-select-label-root")
225225
.should("have.attr", "aria-label", labelText);
226226
});
227+
});
228+
229+
it("should have aria-controls pointing to the responsive popover", () => {
230+
cy.mount(
231+
<Select>
232+
<Option value="option1">Option 1</Option>
233+
<Option value="option2">Option 2</Option>
234+
<Option value="option3">Option 3</Option>
235+
</Select>
236+
);
237+
238+
cy.get("[ui5-select]")
239+
.shadow()
240+
.find("[ui5-responsive-popover]")
241+
.invoke("attr", "id")
242+
.then((popoverId) => {
243+
cy.get("[ui5-select]")
244+
.shadow()
245+
.find(".ui5-select-label-root")
246+
.should("have.attr", "aria-controls", popoverId);
247+
});
227248
});
228249

229250
it("Tests accessibility", () => {

packages/main/src/Select.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,10 @@ class Select extends UI5Element implements IFormInputElement {
899899
return this.hasValueState ? `${this._id}-valueStateDesc` : undefined;
900900
}
901901

902+
get responsivePopoverId() {
903+
return `${this._id}-popover`;
904+
}
905+
902906
get isDisabled() {
903907
return this.disabled || undefined;
904908
}

packages/main/src/SelectPopoverTemplate.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default function SelectPopoverTemplate(this: Select) {
1111
<>
1212
{this.options.length > 0 &&
1313
<ResponsivePopover
14+
id={this.responsivePopoverId}
1415
class={{
1516
"ui5-select-popover": true,
1617
...this.classes.popover

packages/main/src/SelectTemplate.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default function SelectTemplate(this: Select) {
4040
onKeyUp={this._onkeyup}
4141
onFocusIn={this._onfocusin}
4242
onFocusOut={this._onfocusout}
43+
aria-controls={this.responsivePopoverId}
4344
>
4445
{this.hasCustomLabel
4546
? <slot name="label"></slot>

0 commit comments

Comments
 (0)