Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/main/cypress/specs/Select.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,28 @@ describe("Select - Accessibility", () => {
cy.get("@select")
.should("have.attr", "title", "Go home");
});

it("should announce the associated label when Select is focused", () => {
cy.mount(
<>
<label for="sel">Should be the aria-label</label>
<Select id="sel">
<Option value="option1">Option 1</Option>
<Option value="option2">Option 2</Option>
<Option value="option3">Option 3</Option>
</Select>
</>
);

cy.get('label[for="sel"]')
.invoke('text')
.then((labelText) => {
cy.get("[ui5-select]")
.shadow()
.find(".ui5-select-label-root")
.should("have.attr", "aria-label", labelText);
});
});
});

describe("Select - Popover", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/Select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
isTabPrevious,
} from "@ui5/webcomponents-base/dist/Keys.js";
import announce from "@ui5/webcomponents-base/dist/util/InvisibleMessage.js";
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js";
import { getEffectiveAriaLabelText, getAssociatedLabelForTexts } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js";
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
import "@ui5/webcomponents-icons/dist/error.js";
import "@ui5/webcomponents-icons/dist/alert.js";
Expand Down Expand Up @@ -966,7 +966,7 @@ class Select extends UI5Element implements IFormInputElement {
}

get ariaLabelText() {
return getEffectiveAriaLabelText(this);
return getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this);
}

get shouldDisplayDefaultValueStateMessage() {
Expand Down
Loading