Skip to content

Commit 99a0e81

Browse files
authoredJul 8, 2020
fix(ui5-combobox): support aria-label/arial-labelledby and fix aria-expanded (#1916)
1 parent cfd4fa3 commit 99a0e81

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed
 

‎packages/main/src/ComboBox.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
aria-haspopup="listbox"
2323
aria-autocomplete="both"
2424
aria-describedby="{{valueStateTextId}}"
25+
aria-label="{{ariaLabelText}}"
2526
/>
2627

2728
{{#unless readonly}}

‎packages/main/src/ComboBox.js

+33
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
33
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
44
import { isPhone } from "@ui5/webcomponents-base/dist/Device.js";
5+
import getEffectiveAriaLabelText from "@ui5/webcomponents-base/dist/util/getEffectiveAriaLabelText.js";
56
import "@ui5/webcomponents-icons/dist/icons/slim-arrow-down.js";
67
import "@ui5/webcomponents-icons/dist/icons/decline.js";
78
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
@@ -173,6 +174,30 @@ const metadata = {
173174
type: Boolean,
174175
},
175176

177+
/**
178+
* Defines the aria-label attribute for the combo box
179+
* @type {String}
180+
* @defaultvalue: ""
181+
* @private
182+
* @since 1.0.0-rc.8
183+
*/
184+
ariaLabel: {
185+
type: String,
186+
defaultValue: undefined,
187+
},
188+
189+
/**
190+
* Receives id(or many ids) of the elements that label the combo box
191+
* @type {String}
192+
* @defaultvalue ""
193+
* @private
194+
* @since 1.0.0-rc.8
195+
*/
196+
ariaLabelledby: {
197+
type: String,
198+
defaultValue: "",
199+
},
200+
176201
_iconPressed: {
177202
type: Boolean,
178203
noAttribute: true,
@@ -519,6 +544,14 @@ class ComboBox extends UI5Element {
519544
};
520545
}
521546

547+
get open() {
548+
return this.responsivePopover ? this.responsivePopover.opened : false;
549+
}
550+
551+
get ariaLabelText() {
552+
return getEffectiveAriaLabelText(this);
553+
}
554+
522555
static async onDefine() {
523556
await Promise.all([
524557
ComboBoxItem.define(),

‎packages/main/test/pages/ComboBox.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
</style>
4141

4242
<div class="demo-section">
43-
<ui5-combobox id="combo" style="width: 360px;" value="Bulgaria">
43+
<ui5-label id="countryLabel">Select country: </ui5-label>
44+
<ui5-combobox id="combo" style="width: 360px;" value="Bulgaria" aria-labelledby="countryLabel">
4445
<ui5-cb-item text="Algeria"></ui5-cb-item>
4546
<ui5-cb-item text="Argentina"></ui5-cb-item>
4647
<ui5-cb-item text="Australia"></ui5-cb-item>
@@ -54,7 +55,7 @@
5455
<ui5-cb-item text="Chile"></ui5-cb-item>
5556
</ui5-combobox>
5657

57-
<ui5-combobox id="combo2" style="width: 360px;">
58+
<ui5-combobox id="combo2" style="width: 360px;" aria-label="Select destination:">
5859
<ui5-cb-item text="Algeria"></ui5-cb-item>
5960
<ui5-cb-item text="Argentina"></ui5-cb-item>
6061
<ui5-cb-item text="Australia"></ui5-cb-item>

0 commit comments

Comments
 (0)
Please sign in to comment.