Skip to content

Commit

Permalink
fix(ui5-combobox): support aria-label/arial-labelledby and fix aria-e…
Browse files Browse the repository at this point in the history
…xpanded (#1916)
  • Loading branch information
vladitasev committed Jul 8, 2020
1 parent cfd4fa3 commit 99a0e81
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/main/src/ComboBox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
aria-haspopup="listbox"
aria-autocomplete="both"
aria-describedby="{{valueStateTextId}}"
aria-label="{{ariaLabelText}}"
/>

{{#unless readonly}}
Expand Down
33 changes: 33 additions & 0 deletions packages/main/src/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
import { isPhone } from "@ui5/webcomponents-base/dist/Device.js";
import getEffectiveAriaLabelText from "@ui5/webcomponents-base/dist/util/getEffectiveAriaLabelText.js";
import "@ui5/webcomponents-icons/dist/icons/slim-arrow-down.js";
import "@ui5/webcomponents-icons/dist/icons/decline.js";
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
Expand Down Expand Up @@ -173,6 +174,30 @@ const metadata = {
type: Boolean,
},

/**
* Defines the aria-label attribute for the combo box
* @type {String}
* @defaultvalue: ""
* @private
* @since 1.0.0-rc.8
*/
ariaLabel: {
type: String,
defaultValue: undefined,
},

/**
* Receives id(or many ids) of the elements that label the combo box
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.8
*/
ariaLabelledby: {
type: String,
defaultValue: "",
},

_iconPressed: {
type: Boolean,
noAttribute: true,
Expand Down Expand Up @@ -519,6 +544,14 @@ class ComboBox extends UI5Element {
};
}

get open() {
return this.responsivePopover ? this.responsivePopover.opened : false;
}

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

static async onDefine() {
await Promise.all([
ComboBoxItem.define(),
Expand Down
5 changes: 3 additions & 2 deletions packages/main/test/pages/ComboBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
</style>

<div class="demo-section">
<ui5-combobox id="combo" style="width: 360px;" value="Bulgaria">
<ui5-label id="countryLabel">Select country: </ui5-label>
<ui5-combobox id="combo" style="width: 360px;" value="Bulgaria" aria-labelledby="countryLabel">
<ui5-cb-item text="Algeria"></ui5-cb-item>
<ui5-cb-item text="Argentina"></ui5-cb-item>
<ui5-cb-item text="Australia"></ui5-cb-item>
Expand All @@ -54,7 +55,7 @@
<ui5-cb-item text="Chile"></ui5-cb-item>
</ui5-combobox>

<ui5-combobox id="combo2" style="width: 360px;">
<ui5-combobox id="combo2" style="width: 360px;" aria-label="Select destination:">
<ui5-cb-item text="Algeria"></ui5-cb-item>
<ui5-cb-item text="Argentina"></ui5-cb-item>
<ui5-cb-item text="Australia"></ui5-cb-item>
Expand Down

0 comments on commit 99a0e81

Please sign in to comment.