Skip to content

Commit

Permalink
feat(ui5-multicombobox): implement ACC support (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoplashkov authored and ilhan007 committed Nov 18, 2019
1 parent c0b51f5 commit 0a44a92
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 6 deletions.
7 changes: 6 additions & 1 deletion packages/main/src/MultiComboBox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@focusin={{rootFocusIn}}
@focusout={{rootFocusOut}}
>
<span id="{{_id}}-hiddenText-nMore" class="ui5-hidden-text">{{nMoreCountText}}</span>

<ui5-tokenizer slot="_beginContent"
show-more
class="ui5-multi-combobox-tokenizer"
Expand Down Expand Up @@ -30,7 +32,10 @@
@keydown="{{_onkeydown}}"
@keyup="{{_onkeyup}}"
@focusin="{{_focusin}}"
@focusout="{{_focusout}}">
@focusout="{{_focusout}}"
role="combobox"
aria-haspopup="listbox"
aria-labelledby="{{_id}}-hiddenText-nMore">
</input>

{{#unless readonly}}
Expand Down
8 changes: 8 additions & 0 deletions packages/main/src/MultiComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import {
import "./icons/slim-arrow-down.js";
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
import { isIE } from "@ui5/webcomponents-core/dist/sap/ui/Device.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import MultiComboBoxTemplate from "./generated/templates/MultiComboBoxTemplate.lit.js";
import Tokenizer from "./Tokenizer.js";
import Token from "./Token.js";
import Icon from "./Icon.js";
import Popover from "./Popover.js";
import List from "./List.js";
import StandardListItem from "./StandardListItem.js";
import { TOKENIZER_ARIA_CONTAIN_SEVERAL_TOKENS } from "../dist/generated/i18n/i18n-defaults.js";

// Styles
import styles from "./generated/themes/MultiComboBox.css.js";
Expand Down Expand Up @@ -275,6 +277,7 @@ class MultiComboBox extends UI5Element {
this._inputLastValue = "";
this._deleting = false;
this._validationTimeout = null;
this.i18nBundle = getI18nBundle("@ui5/webcomponents");
}

_inputChange() {
Expand Down Expand Up @@ -490,6 +493,10 @@ class MultiComboBox extends UI5Element {
return this.shadowRoot.querySelector("ui5-tokenizer");
}

get nMoreCountText() {
return this.i18nBundle.getText(TOKENIZER_ARIA_CONTAIN_SEVERAL_TOKENS, this._getSelectedItems().length);
}

rootFocusIn() {
this.expandedTokenizer = true;
}
Expand Down Expand Up @@ -520,6 +527,7 @@ class MultiComboBox extends UI5Element {
Popover.define(),
List.define(),
StandardListItem.define(),
fetchI18nBundle("@ui5/webcomponents"),
]);

super.define(...params);
Expand Down
18 changes: 16 additions & 2 deletions packages/main/src/Token.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
<div tabindex="{{_tabIndex}}" @click="{{_select}}" @keydown="{{_keydown}}" class="ui5-token--wrapper" dir="{{dir}}">
<div
tabindex="{{_tabIndex}}"
@click="{{_select}}"
@keydown="{{_keydown}}"
class="ui5-token--wrapper"
dir="{{dir}}"
role="option"
aria-selected="{{selected}}"
>
<span class="ui5-token--text"><slot></slot></span>

{{#unless readonly}}
<ui5-icon @click="{{_delete}}" name="{{iconURI}}" accessible-name="{{tokenDeletableText}}" show-tooltip="true" class="ui5-token--icon"></ui5-icon>
<ui5-icon
@click="{{_delete}}"
src="{{iconURI}}"
accessible-name="{{tokenDeletableText}}"
show-tooltip
class="ui5-token--icon"
></ui5-icon>
{{/unless}}
</div>
18 changes: 15 additions & 3 deletions packages/main/src/Tokenizer.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<div class="{{classes.wrapper}}">
<div class="{{classes.content}}" @ui5-delete={{_tokenDelete}}>
<div
class="{{classes.wrapper}}"
>
<span id="{{_id}}-hiddenText" class="ui5-hidden-text">{{tokenizerLabel}}</span>

<div
class="{{classes.content}}"
@ui5-delete="{{_tokenDelete}}"
role="listbox"
aria-labelledby="{{_id}}-hiddenText"
>
{{#each tokens}}
<slot name="{{this._individualSlot}}"></slot>
{{/each}}
</div>

{{#if showNMore}}
<span @click="{{_openOverflowPopover}}" class="ui5-tokenizer-more-text">{{_nMoreText}}</span>
<span
@click="{{_openOverflowPopover}}"
class="ui5-tokenizer-more-text"
>{{_nMoreText}}</span>
{{/if}}
</div>
5 changes: 5 additions & 0 deletions packages/main/src/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import TokenizerTemplate from "./generated/templates/TokenizerTemplate.lit.js";
import { MULTIINPUT_SHOW_MORE_TOKENS } from "./generated/i18n/i18n-defaults.js";
import { TOKENIZER_ARIA_LABEL } from "../dist/generated/i18n/i18n-defaults.js";

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

get tokenizerLabel() {
return this.i18nBundle.getText(TOKENIZER_ARIA_LABEL);
}

get overflownTokens() {
if (!this.contentDom) {
return [];
Expand Down
6 changes: 6 additions & 0 deletions packages/main/src/i18n/messagebundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ TEXTAREA_CHARACTERS_EXCEEDED={0} characters over limit
#XACT: ARIA announcement for token deletable
TOKEN_ARIA_DELETABLE=Deletable

#XACT: ARIA announcement for tokenizer with n tokens
TOKENIZER_ARIA_CONTAIN_SEVERAL_TOKENS=Contains {0} tokens

#XACT: ARIA announcement for tokenizer label
TOKENIZER_ARIA_LABEL=Tokenizer

#XTOL: text that is appended to the tooltips of input fields etc. which are marked to have an error
VALUE_STATE_ERROR=Invalid entry

Expand Down
1 change: 1 addition & 0 deletions packages/main/src/themes/MultiComboBox.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "./Input.css";
@import "./InputIcon.css";
@import "./InvisibleTextStyles.css";

:host(:not([hidden])) {
display: inline-block;
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/Tokenizer.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "./InvisibleTextStyles.css";

:host {
display: inline-block;
box-sizing: border-box;
Expand Down

0 comments on commit 0a44a92

Please sign in to comment.