File tree Expand file tree Collapse file tree 4 files changed +58
-4
lines changed Expand file tree Collapse file tree 4 files changed +58
-4
lines changed Original file line number Diff line number Diff line change @@ -168,4 +168,31 @@ describe("Event firing", () => {
168
168
cy . get ( "@changeStub" ) . should ( "not.have.been.called" ) ;
169
169
} ) ;
170
170
} ) ;
171
+ describe ( "Accessibility" , ( ) => {
172
+ it ( "should announce the associated label when ComboBox is focused" , ( ) => {
173
+ cy . mount (
174
+ < >
175
+ < label for = "cb" > Should be the aria-label</ label >
176
+ < ComboBox id = "cb" />
177
+ </ >
178
+ ) ;
179
+
180
+ cy . get ( 'label[for="cb"]' )
181
+ . invoke ( 'text' )
182
+ . then ( ( labelText ) => {
183
+
184
+ cy . get ( "[ui5-combobox]" )
185
+ . shadow ( )
186
+ . find ( "input" )
187
+ . as ( "innerInput" ) ;
188
+
189
+ cy . get ( "@innerInput" )
190
+ . click ( ) ;
191
+
192
+ cy . get ( "@innerInput" )
193
+ . should ( "have.attr" , "aria-label" , labelText ) ;
194
+ } ) ;
195
+ } ) ;
196
+ } ) ;
197
+
171
198
Original file line number Diff line number Diff line change @@ -160,3 +160,30 @@ describe("Event firing", () => {
160
160
. should ( "have.been.calledTwice" ) ;
161
161
} ) ;
162
162
} ) ;
163
+
164
+ describe ( "Accessibility" , ( ) => {
165
+ it ( "should announce the associated label when MultiComboBox is focused" , ( ) => {
166
+ cy . mount (
167
+ < >
168
+ < label for = "mcb" > MultiComboBox aria-label</ label >
169
+ < MultiComboBox id = "mcb" > </ MultiComboBox >
170
+ </ >
171
+ ) ;
172
+
173
+ cy . get ( 'label[for="mcb"]' )
174
+ . invoke ( 'text' )
175
+ . then ( ( labelText ) => {
176
+
177
+ cy . get ( "[ui5-multi-combobox]" )
178
+ . shadow ( )
179
+ . find ( "input" )
180
+ . as ( "innerInput" ) ;
181
+
182
+ cy . get ( "@innerInput" )
183
+ . click ( ) ;
184
+
185
+ cy . get ( "@innerInput" )
186
+ . should ( "have.attr" , "aria-label" , labelText ) ;
187
+ } ) ;
188
+ } ) ;
189
+ } ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
7
7
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
8
8
import { isPhone , isAndroid } from "@ui5/webcomponents-base/dist/Device.js" ;
9
9
import InvisibleMessageMode from "@ui5/webcomponents-base/dist/types/InvisibleMessageMode.js" ;
10
- import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js" ;
10
+ import { getEffectiveAriaLabelText , getAssociatedLabelForTexts } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js" ;
11
11
import announce from "@ui5/webcomponents-base/dist/util/InvisibleMessage.js" ;
12
12
import { getScopedVarName } from "@ui5/webcomponents-base/dist/CustomElementsScope.js" ;
13
13
import "@ui5/webcomponents-icons/dist/slim-arrow-down.js" ;
@@ -1351,7 +1351,7 @@ class ComboBox extends UI5Element implements IFormInputElement {
1351
1351
}
1352
1352
1353
1353
get ariaLabelText ( ) : string | undefined {
1354
- return getEffectiveAriaLabelText ( this ) ;
1354
+ return getEffectiveAriaLabelText ( this ) || getAssociatedLabelForTexts ( this ) ;
1355
1355
}
1356
1356
1357
1357
get clearIconAccessibleName ( ) {
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ import "@ui5/webcomponents-icons/dist/error.js";
49
49
import "@ui5/webcomponents-icons/dist/alert.js" ;
50
50
import "@ui5/webcomponents-icons/dist/sys-enter-2.js" ;
51
51
import "@ui5/webcomponents-icons/dist/information.js" ;
52
- import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js" ;
52
+ import { getAssociatedLabelForTexts , getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js" ;
53
53
import { getScopedVarName } from "@ui5/webcomponents-base/dist/CustomElementsScope.js" ;
54
54
import { submitForm } from "@ui5/webcomponents-base/dist/features/InputElementsFormSupport.js" ;
55
55
import type { IFormInputElement } from "@ui5/webcomponents-base/dist/features/InputElementsFormSupport.js" ;
@@ -1868,7 +1868,7 @@ class MultiComboBox extends UI5Element implements IFormInputElement {
1868
1868
}
1869
1869
1870
1870
get ariaLabelText ( ) {
1871
- return getEffectiveAriaLabelText ( this ) ;
1871
+ return getEffectiveAriaLabelText ( this ) || getAssociatedLabelForTexts ( this ) ;
1872
1872
}
1873
1873
1874
1874
/**
You can’t perform that action at this time.
0 commit comments