Skip to content

Commit 0a44a92

Browse files
ivoplashkovilhan007
authored andcommittedNov 18, 2019
feat(ui5-multicombobox): implement ACC support (#937)
1 parent c0b51f5 commit 0a44a92

File tree

8 files changed

+59
-6
lines changed

8 files changed

+59
-6
lines changed
 

‎packages/main/src/MultiComboBox.hbs

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@focusin={{rootFocusIn}}
33
@focusout={{rootFocusOut}}
44
>
5+
<span id="{{_id}}-hiddenText-nMore" class="ui5-hidden-text">{{nMoreCountText}}</span>
6+
57
<ui5-tokenizer slot="_beginContent"
68
show-more
79
class="ui5-multi-combobox-tokenizer"
@@ -30,7 +32,10 @@
3032
@keydown="{{_onkeydown}}"
3133
@keyup="{{_onkeyup}}"
3234
@focusin="{{_focusin}}"
33-
@focusout="{{_focusout}}">
35+
@focusout="{{_focusout}}"
36+
role="combobox"
37+
aria-haspopup="listbox"
38+
aria-labelledby="{{_id}}-hiddenText-nMore">
3439
</input>
3540

3641
{{#unless readonly}}

‎packages/main/src/MultiComboBox.js

+8
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import {
77
import "./icons/slim-arrow-down.js";
88
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
99
import { isIE } from "@ui5/webcomponents-core/dist/sap/ui/Device.js";
10+
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
1011
import MultiComboBoxTemplate from "./generated/templates/MultiComboBoxTemplate.lit.js";
1112
import Tokenizer from "./Tokenizer.js";
1213
import Token from "./Token.js";
1314
import Icon from "./Icon.js";
1415
import Popover from "./Popover.js";
1516
import List from "./List.js";
1617
import StandardListItem from "./StandardListItem.js";
18+
import { TOKENIZER_ARIA_CONTAIN_SEVERAL_TOKENS } from "../dist/generated/i18n/i18n-defaults.js";
1719

1820
// Styles
1921
import styles from "./generated/themes/MultiComboBox.css.js";
@@ -275,6 +277,7 @@ class MultiComboBox extends UI5Element {
275277
this._inputLastValue = "";
276278
this._deleting = false;
277279
this._validationTimeout = null;
280+
this.i18nBundle = getI18nBundle("@ui5/webcomponents");
278281
}
279282

280283
_inputChange() {
@@ -490,6 +493,10 @@ class MultiComboBox extends UI5Element {
490493
return this.shadowRoot.querySelector("ui5-tokenizer");
491494
}
492495

496+
get nMoreCountText() {
497+
return this.i18nBundle.getText(TOKENIZER_ARIA_CONTAIN_SEVERAL_TOKENS, this._getSelectedItems().length);
498+
}
499+
493500
rootFocusIn() {
494501
this.expandedTokenizer = true;
495502
}
@@ -520,6 +527,7 @@ class MultiComboBox extends UI5Element {
520527
Popover.define(),
521528
List.define(),
522529
StandardListItem.define(),
530+
fetchI18nBundle("@ui5/webcomponents"),
523531
]);
524532

525533
super.define(...params);

‎packages/main/src/Token.hbs

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
<div tabindex="{{_tabIndex}}" @click="{{_select}}" @keydown="{{_keydown}}" class="ui5-token--wrapper" dir="{{dir}}">
1+
<div
2+
tabindex="{{_tabIndex}}"
3+
@click="{{_select}}"
4+
@keydown="{{_keydown}}"
5+
class="ui5-token--wrapper"
6+
dir="{{dir}}"
7+
role="option"
8+
aria-selected="{{selected}}"
9+
>
210
<span class="ui5-token--text"><slot></slot></span>
311

412
{{#unless readonly}}
5-
<ui5-icon @click="{{_delete}}" name="{{iconURI}}" accessible-name="{{tokenDeletableText}}" show-tooltip="true" class="ui5-token--icon"></ui5-icon>
13+
<ui5-icon
14+
@click="{{_delete}}"
15+
src="{{iconURI}}"
16+
accessible-name="{{tokenDeletableText}}"
17+
show-tooltip
18+
class="ui5-token--icon"
19+
></ui5-icon>
620
{{/unless}}
721
</div>

‎packages/main/src/Tokenizer.hbs

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
<div class="{{classes.wrapper}}">
2-
<div class="{{classes.content}}" @ui5-delete={{_tokenDelete}}>
1+
<div
2+
class="{{classes.wrapper}}"
3+
>
4+
<span id="{{_id}}-hiddenText" class="ui5-hidden-text">{{tokenizerLabel}}</span>
5+
6+
<div
7+
class="{{classes.content}}"
8+
@ui5-delete="{{_tokenDelete}}"
9+
role="listbox"
10+
aria-labelledby="{{_id}}-hiddenText"
11+
>
312
{{#each tokens}}
413
<slot name="{{this._individualSlot}}"></slot>
514
{{/each}}
615
</div>
716

817
{{#if showNMore}}
9-
<span @click="{{_openOverflowPopover}}" class="ui5-tokenizer-more-text">{{_nMoreText}}</span>
18+
<span
19+
@click="{{_openOverflowPopover}}"
20+
class="ui5-tokenizer-more-text"
21+
>{{_nMoreText}}</span>
1022
{{/if}}
1123
</div>

‎packages/main/src/Tokenizer.js

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation
55
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
66
import TokenizerTemplate from "./generated/templates/TokenizerTemplate.lit.js";
77
import { MULTIINPUT_SHOW_MORE_TOKENS } from "./generated/i18n/i18n-defaults.js";
8+
import { TOKENIZER_ARIA_LABEL } from "../dist/generated/i18n/i18n-defaults.js";
89

910
// Styles
1011
import styles from "./generated/themes/Tokenizer.css.js";
@@ -182,6 +183,10 @@ class Tokenizer extends UI5Element {
182183
return this.shadowRoot.querySelector(".ui5-tokenizer--content");
183184
}
184185

186+
get tokenizerLabel() {
187+
return this.i18nBundle.getText(TOKENIZER_ARIA_LABEL);
188+
}
189+
185190
get overflownTokens() {
186191
if (!this.contentDom) {
187192
return [];

‎packages/main/src/i18n/messagebundle.properties

+6
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ TEXTAREA_CHARACTERS_EXCEEDED={0} characters over limit
253253
#XACT: ARIA announcement for token deletable
254254
TOKEN_ARIA_DELETABLE=Deletable
255255

256+
#XACT: ARIA announcement for tokenizer with n tokens
257+
TOKENIZER_ARIA_CONTAIN_SEVERAL_TOKENS=Contains {0} tokens
258+
259+
#XACT: ARIA announcement for tokenizer label
260+
TOKENIZER_ARIA_LABEL=Tokenizer
261+
256262
#XTOL: text that is appended to the tooltips of input fields etc. which are marked to have an error
257263
VALUE_STATE_ERROR=Invalid entry
258264

‎packages/main/src/themes/MultiComboBox.css

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import "./Input.css";
22
@import "./InputIcon.css";
3+
@import "./InvisibleTextStyles.css";
34

45
:host(:not([hidden])) {
56
display: inline-block;

‎packages/main/src/themes/Tokenizer.css

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "./InvisibleTextStyles.css";
2+
13
:host {
24
display: inline-block;
35
box-sizing: border-box;

0 commit comments

Comments
 (0)
Please sign in to comment.