Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-combobox): support arial-labelledby and fix aria-expanded #1916

Merged
merged 1 commit into from
Jul 8, 2020
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
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