From 194185400bb70a778359a721928ad3a99bd5f3a6 Mon Sep 17 00:00:00 2001 From: niyap <38278268+niyap@users.noreply.github.com> Date: Mon, 30 Oct 2023 11:26:18 +0200 Subject: [PATCH] fix(ui5-combobox): announce value state header on focus (#7751) * fix(ui5-combobox): announce value state header on focus * fix(ui5-combobox): announce default value state text * fix(ui5-combobox): adjust condition --- packages/main/src/ComboBox.ts | 12 ++++++++++++ packages/main/test/pages/ComboBox.html | 13 +++++++++++++ packages/main/test/specs/ComboBox.spec.js | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/packages/main/src/ComboBox.ts b/packages/main/src/ComboBox.ts index 3e61961d5e5e..0766e275fcb6 100644 --- a/packages/main/src/ComboBox.ts +++ b/packages/main/src/ComboBox.ts @@ -769,6 +769,7 @@ class ComboBox extends UI5Element { if (this.focused && indexOfItem === -1 && this.hasValueStateText && isOpen) { this._isValueStateFocused = true; + this._announceValueStateText(); this.focused = false; return; } @@ -792,6 +793,7 @@ class ComboBox extends UI5Element { this._clearFocus(); this._itemFocused = false; this._isValueStateFocused = true; + this._announceValueStateText(); this._filteredItems[0].selected = false; return; } @@ -815,6 +817,7 @@ class ComboBox extends UI5Element { this._clearFocus(); this._itemFocused = false; this._isValueStateFocused = true; + this._announceValueStateText(); return; } @@ -838,6 +841,7 @@ class ComboBox extends UI5Element { this._clearFocus(); this._itemFocused = false; this._isValueStateFocused = true; + this._announceValueStateText(); return; } @@ -1073,6 +1077,14 @@ class ComboBox extends UI5Element { } } + _announceValueStateText() { + const valueStateText = this.shouldDisplayDefaultValueStateMessage ? this.valueStateDefaultText : this.valueStateMessageText.map(el => el.textContent).join(" "); + + if (valueStateText) { + announce(valueStateText, InvisibleMessageMode.Polite); + } + } + get _headerTitleText() { return ComboBox.i18nBundle.getText(INPUT_SUGGESTIONS_TITLE); } diff --git a/packages/main/test/pages/ComboBox.html b/packages/main/test/pages/ComboBox.html index 82730131ddec..1ff451382f70 100644 --- a/packages/main/test/pages/ComboBox.html +++ b/packages/main/test/pages/ComboBox.html @@ -287,6 +287,19 @@

ComboBox in Compact

+
+ + + + + + + + +
Please choose a country
+
+
+