Skip to content

Commit 82317d0

Browse files
authored
fix(ui5-input, ui5-multi-input, ui5-combobox, ui5-multi-combobox): announce value state type (#5515)
* fix(ui5-input, ui5-multi-input, ui5-combobox, ui5-multi-combobox): announce value state type related to #5392 * fix(ui5-input, ui5-multi-input, ui5-combobox, ui5-multi-combobox): announce value state type restore ui5-multi-input test page * fix(ui5-input, ui5-multi-input, ui5-combobox, ui5-multi-combobox): announce value state type fix messagebundle comments
1 parent 2b51b87 commit 82317d0

14 files changed

+262
-23
lines changed

packages/main/src/ComboBox.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="ui5-combobox-root ui5-input-focusable-element">
22
{{#if hasValueState}}
3-
<span id="{{_id}}-valueStateDesc" class="ui5-hidden-text">{{valueStateText}}</span>
3+
<span id="{{_id}}-valueStateDesc" class="ui5-hidden-text">{{ariaValueStateHiddenText}}</span>
44
{{/if}}
55

66
<input id="ui5-combobox-input"

packages/main/src/ComboBox.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ import {
3636
VALUE_STATE_ERROR,
3737
VALUE_STATE_WARNING,
3838
VALUE_STATE_INFORMATION,
39+
VALUE_STATE_TYPE_SUCCESS,
40+
VALUE_STATE_TYPE_INFORMATION,
41+
VALUE_STATE_TYPE_ERROR,
42+
VALUE_STATE_TYPE_WARNING,
3943
INPUT_SUGGESTIONS_TITLE,
4044
SELECT_OPTIONS,
4145
LIST_ITEM_POSITION,
@@ -1009,7 +1013,19 @@ class ComboBox extends UI5Element {
10091013
return this.hasValueState && this.valueState !== ValueState.Success;
10101014
}
10111015

1012-
get valueStateText() {
1016+
get ariaValueStateHiddenText() {
1017+
if (!this.hasValueState) {
1018+
return;
1019+
}
1020+
1021+
if (this.shouldDisplayDefaultValueStateMessage) {
1022+
return `${this.valueStateTypeMappings[this.valueState]} ${this.valueStateDefaultText}`;
1023+
}
1024+
1025+
return `${this.valueStateTypeMappings[this.valueState]}`.concat(" ", this.valueStateMessageText.map(el => el.textContent).join(" "));
1026+
}
1027+
1028+
get valueStateDefaultText() {
10131029
return this.valueStateTextMappings[this.valueState];
10141030
}
10151031

@@ -1030,6 +1046,15 @@ class ComboBox extends UI5Element {
10301046
};
10311047
}
10321048

1049+
get valueStateTypeMappings() {
1050+
return {
1051+
"Success": ComboBox.i18nBundle.getText(VALUE_STATE_TYPE_SUCCESS),
1052+
"Information": ComboBox.i18nBundle.getText(VALUE_STATE_TYPE_INFORMATION),
1053+
"Error": ComboBox.i18nBundle.getText(VALUE_STATE_TYPE_ERROR),
1054+
"Warning": ComboBox.i18nBundle.getText(VALUE_STATE_TYPE_WARNING),
1055+
};
1056+
}
1057+
10331058
get shouldOpenValueStateMessagePopover() {
10341059
return this.focused && !this.readonly && this.hasValueStateText && !this._iconPressed
10351060
&& !this.open && !this._isPhone;

packages/main/src/ComboBoxPopover.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118

119119
{{#*inline "valueStateMessage"}}
120120
{{#if shouldDisplayDefaultValueStateMessage}}
121-
{{valueStateText}}
121+
{{valueStateDefaultText}}
122122
{{else}}
123123
{{#each valueStateMessageText}}
124124
{{this}}

packages/main/src/Input.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ import {
4646
VALUE_STATE_INFORMATION,
4747
VALUE_STATE_ERROR,
4848
VALUE_STATE_WARNING,
49+
VALUE_STATE_TYPE_SUCCESS,
50+
VALUE_STATE_TYPE_INFORMATION,
51+
VALUE_STATE_TYPE_ERROR,
52+
VALUE_STATE_TYPE_WARNING,
4953
INPUT_SUGGESTIONS,
5054
INPUT_SUGGESTIONS_TITLE,
5155
INPUT_SUGGESTIONS_ONE_HIT,
@@ -1377,6 +1381,15 @@ class Input extends UI5Element {
13771381

13781382
onClose() {}
13791383

1384+
get valueStateTypeMappings() {
1385+
return {
1386+
"Success": Input.i18nBundle.getText(VALUE_STATE_TYPE_SUCCESS),
1387+
"Information": Input.i18nBundle.getText(VALUE_STATE_TYPE_INFORMATION),
1388+
"Error": Input.i18nBundle.getText(VALUE_STATE_TYPE_ERROR),
1389+
"Warning": Input.i18nBundle.getText(VALUE_STATE_TYPE_WARNING),
1390+
};
1391+
}
1392+
13801393
valueStateTextMappings() {
13811394
return {
13821395
"Success": Input.i18nBundle.getText(VALUE_STATE_SUCCESS),
@@ -1450,15 +1463,15 @@ class Input extends UI5Element {
14501463
}
14511464

14521465
get ariaValueStateHiddenText() {
1453-
if (!this.hasValueStateMessage) {
1466+
if (!this.hasValueState) {
14541467
return;
14551468
}
14561469

14571470
if (this.shouldDisplayDefaultValueStateMessage) {
1458-
return this.valueStateText;
1471+
return `${this.valueStateTypeMappings[this.valueState]} ${this.valueStateText}`;
14591472
}
14601473

1461-
return this.valueStateMessageText.map(el => el.textContent).join(" ");
1474+
return `${this.valueStateTypeMappings[this.valueState]}`.concat(" ", this.valueStateMessageText.map(el => el.textContent).join(" "));
14621475
}
14631476

14641477
get itemSelectionAnnounce() {

packages/main/src/MultiComboBox.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<span id="{{_id}}-hiddenText-nMore" class="ui5-hidden-text">{{_tokensCountText}}</span>
44

55
{{#if hasValueState}}
6-
<span id="{{_id}}-valueStateDesc" class="ui5-hidden-text">{{valueStateText}}</span>
6+
<span id="{{_id}}-valueStateDesc" class="ui5-hidden-text">{{ariaValueStateHiddenText}}</span>
77
{{/if}}
88

99
<ui5-tokenizer slot="_beginContent"

packages/main/src/MultiComboBox.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ import {
6565
VALUE_STATE_ERROR,
6666
VALUE_STATE_WARNING,
6767
VALUE_STATE_INFORMATION,
68+
VALUE_STATE_TYPE_SUCCESS,
69+
VALUE_STATE_TYPE_INFORMATION,
70+
VALUE_STATE_TYPE_ERROR,
71+
VALUE_STATE_TYPE_WARNING,
6872
INPUT_SUGGESTIONS_TITLE,
6973
SELECT_OPTIONS,
7074
MULTICOMBOBOX_DIALOG_OK_BUTTON,
@@ -1447,7 +1451,19 @@ class MultiComboBox extends UI5Element {
14471451
return this.hasValueState && this.valueState !== ValueState.Success;
14481452
}
14491453

1450-
get valueStateText() {
1454+
get ariaValueStateHiddenText() {
1455+
if (!this.hasValueState) {
1456+
return;
1457+
}
1458+
1459+
if (this.shouldDisplayDefaultValueStateMessage) {
1460+
return `${this.valueStateTypeMappings[this.valueState]} ${this.valueStateDefaultText}`;
1461+
}
1462+
1463+
return `${this.valueStateTypeMappings[this.valueState]}`.concat(" ", this.valueStateMessageText.map(el => el.textContent).join(" "));
1464+
}
1465+
1466+
get valueStateDefaultText() {
14511467
let key = this.valueState;
14521468

14531469
if (this._performingSelectionTwice) {
@@ -1520,6 +1536,15 @@ class MultiComboBox extends UI5Element {
15201536
};
15211537
}
15221538

1539+
get valueStateTypeMappings() {
1540+
return {
1541+
"Success": MultiComboBox.i18nBundle.getText(VALUE_STATE_TYPE_SUCCESS),
1542+
"Information": MultiComboBox.i18nBundle.getText(VALUE_STATE_TYPE_INFORMATION),
1543+
"Error": MultiComboBox.i18nBundle.getText(VALUE_STATE_TYPE_ERROR),
1544+
"Warning": MultiComboBox.i18nBundle.getText(VALUE_STATE_TYPE_WARNING),
1545+
};
1546+
}
1547+
15231548
get _innerInput() {
15241549
if (isPhone()) {
15251550
if (this.allItemsPopover && this.allItemsPopover.opened) {

packages/main/src/MultiComboBoxPopover.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120

121121
{{#*inline "valueStateMessage"}}
122122
{{#if shouldDisplayDefaultValueStateMessage}}
123-
{{valueStateText}}
123+
{{valueStateDefaultText}}
124124
{{else}}
125125
{{#each valueStateMessageText}}
126126
{{this}}

packages/main/src/i18n/messagebundle.properties

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,21 @@ TREE_ITEM_ARIA_LABEL=Tree Item
343343
#XTOL: tooltip for expand icon in a tree item
344344
TREE_ITEM_EXPAND_NODE=Expand Node
345345

346-
#XTOL: tooltip for collapse icon in a tree item
346+
#XACT: tooltip for collapse icon in a tree item
347347
TREE_ITEM_COLLAPSE_NODE=Collapse Node
348348

349+
#XACT: the value state type that is preppended to value state error message text
350+
VALUE_STATE_TYPE_ERROR=Value State Error
351+
352+
#XACT: the value state type that is preppended to value state warning message text
353+
VALUE_STATE_TYPE_WARNING=Value State Warning
354+
355+
#XACT: the value state type that is preppended to value state success message text
356+
VALUE_STATE_TYPE_SUCCESS=Value State Success
357+
358+
#XACT: the value state type that is preppended to value state information message text
359+
VALUE_STATE_TYPE_INFORMATION=Value State Information
360+
349361
#XTOL: text that is appended to the tooltips of input fields etc. which are marked to have an error
350362
VALUE_STATE_ERROR=Invalid entry
351363

packages/main/test/pages/ComboBox.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@
7171
<ui5-cb-item text="Bahrain"></ui5-cb-item>
7272
<ui5-cb-item text="Belgium"></ui5-cb-item>
7373
<ui5-cb-item text="Bosnia and Herzegovina"></ui5-cb-item>
74-
<div slot="valueStateMessage">Information message. This is a <a href="#test1">Link</a>. Extra long text used as an information message. Extra long text used as an information message - 2. Extra long text used as an information message - 3.</div>
75-
<div slot="valueStateMessage">Information message 2. This is a <a href="#test2">Link</a>. Extra long text used as an information message. Extra long text used as an information message - 2. Extra long text used as an information message - 3.</div>
74+
<div slot="valueStateMessage">Custom error value state message with a <a href="#">Link</a>.</div>
75+
<div slot="valueStateMessage">Additionl custom error value state message with a <a href="#">Link</a>. Extra long text used as an error message. Extra long text used as an error message - 2. Extra long text used as an error message - 3.</div>
7676
</ui5-combobox>
77-
<ui5-combobox id="" class="combobox2auto" value-state="Warning">
77+
<ui5-combobox id="vs-warning-default" class="combobox2auto" value-state="Warning">
7878
<ui5-cb-item text="Algeria"></ui5-cb-item>
7979
<ui5-cb-item text="Argentina"></ui5-cb-item>
8080
<ui5-cb-item text="Australia"></ui5-cb-item>
8181
<ui5-cb-item text="Austria"></ui5-cb-item>
8282
<ui5-cb-item text="Bahrain"></ui5-cb-item>
8383
<ui5-cb-item text="Belgium"></ui5-cb-item>
8484
</ui5-combobox>
85-
<ui5-combobox id="" class="combobox2auto" value-state="Information"></ui5-combobox>
86-
<ui5-combobox id="" class="combobox2auto" value-state="Success"></ui5-combobox>
85+
<ui5-combobox id="vs-information-default" class="combobox2auto" value-state="Information"></ui5-combobox>
86+
<ui5-combobox id="vs-success-default" class="combobox2auto" value-state="Success"></ui5-combobox>
8787
</div>
8888

8989
<div class="demo-section">

packages/main/test/pages/Input.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ <h3>Input with valueState and Dynamic suggestions</h3>
9999
show-suggestions
100100
value-state="Error"
101101
placeholder="Search for a country ...">
102-
<div slot="valueStateMessage">Information message. This is a <a href="#">Link</a>. Extra long text used as an information message. Extra long text used as an information message - 2. Extra long text used as an information message - 3.</div>
103-
<div slot="valueStateMessage">Information message 2. This is a <a href="#">Link</a>. Extra long text used as an information message. Extra long text used as an information message - 2. Extra long text used as an information message - 3.</div>
102+
<div slot="valueStateMessage">Custom error value state message with a <a href="#">Link</a>.</div>
103+
<div slot="valueStateMessage">Additionl custom error value state message with a <a href="#">Link</a>. Extra long text used as an error message. Extra long text used as an error message - 2. Extra long text used as an error message - 3.</div>
104104
</ui5-input>
105105

106106
<h3>Input with long suggestions with valueState and ui5-li</h3>
@@ -348,10 +348,10 @@ <h3>sap_horizon</h3>
348348
<ui5-input placeholder="No Value State"></ui5-input>
349349
<ui5-input placeholder="Disabled" disabled></ui5-input>
350350
<ui5-input placeholder="ReadnOnly" readonly></ui5-input>
351-
<ui5-input placeholder="Error ValueState" value-state="Error"></ui5-input>
352-
<ui5-input placeholder="Warning ValueState" value-state="Warning"></ui5-input>
353-
<ui5-input placeholder="Success ValueState" value-state="Success"></ui5-input>
354-
<ui5-input placeholder="Information ValueState" value-state="Information"></ui5-input>
351+
<ui5-input id="vs-error-default" placeholder="Error ValueState" value-state="Error"></ui5-input>
352+
<ui5-input id="vs-warning-default" placeholder="Warning ValueState" value-state="Warning"></ui5-input>
353+
<ui5-input id="vs-success-default" placeholder="Success ValueState" value-state="Success"></ui5-input>
354+
<ui5-input id="vs-information-default" placeholder="Information ValueState" value-state="Information"></ui5-input>
355355
</div>
356356

357357
<br>

0 commit comments

Comments
 (0)