File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,28 @@ describe("Select - Accessibility", () => {
203
203
cy . get ( "@select" )
204
204
. should ( "have.attr" , "title" , "Go home" ) ;
205
205
} ) ;
206
+
207
+ it ( "should announce the associated label when Select is focused" , ( ) => {
208
+ cy . mount (
209
+ < >
210
+ < label for = "sel" > Should be the aria-label</ label >
211
+ < Select id = "sel" >
212
+ < Option value = "option1" > Option 1</ Option >
213
+ < Option value = "option2" > Option 2</ Option >
214
+ < Option value = "option3" > Option 3</ Option >
215
+ </ Select >
216
+ </ >
217
+ ) ;
218
+
219
+ cy . get ( 'label[for="sel"]' )
220
+ . invoke ( 'text' )
221
+ . then ( ( labelText ) => {
222
+ cy . get ( "[ui5-select]" )
223
+ . shadow ( )
224
+ . find ( ".ui5-select-label-root" )
225
+ . should ( "have.attr" , "aria-label" , labelText ) ;
226
+ } ) ;
227
+ } ) ;
206
228
} ) ;
207
229
208
230
describe ( "Select - Popover" , ( ) => {
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import {
17
17
isTabPrevious ,
18
18
} from "@ui5/webcomponents-base/dist/Keys.js" ;
19
19
import announce from "@ui5/webcomponents-base/dist/util/InvisibleMessage.js" ;
20
- import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js" ;
20
+ import { getEffectiveAriaLabelText , getAssociatedLabelForTexts } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js" ;
21
21
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
22
22
import "@ui5/webcomponents-icons/dist/error.js" ;
23
23
import "@ui5/webcomponents-icons/dist/alert.js" ;
@@ -966,7 +966,7 @@ class Select extends UI5Element implements IFormInputElement {
966
966
}
967
967
968
968
get ariaLabelText ( ) {
969
- return getEffectiveAriaLabelText ( this ) ;
969
+ return getEffectiveAriaLabelText ( this ) || getAssociatedLabelForTexts ( this ) ;
970
970
}
971
971
972
972
get shouldDisplayDefaultValueStateMessage ( ) {
You can’t perform that action at this time.
0 commit comments