Skip to content

Commit

Permalink
fix(ui5-combobox): remove the cloning of the value state message (#9384)
Browse files Browse the repository at this point in the history
* fix(ui5-combobox): remove the cloning of the value state message

related to #9347
  • Loading branch information
ndeshev authored Jul 16, 2024
1 parent 2ea26ca commit a24c6b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
10 changes: 3 additions & 7 deletions packages/main/src/ComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ class ComboBox extends UI5Element implements IFormInputElement {
this._fireChangeEvent();

const focusedOutToItemsPicker = this.open && this._getPicker().contains(toBeFocused);
const focusedOutToValueState = this.valueStateOpen && this._getValueStatePopover().contains(toBeFocused);
const focusedOutToValueState = this.valueStateOpen && this.contains(toBeFocused);

if (focusedOutToItemsPicker || focusedOutToValueState) {
e.stopImmediatePropagation();
Expand Down Expand Up @@ -1221,7 +1221,7 @@ class ComboBox extends UI5Element implements IFormInputElement {
}

_announceValueStateText() {
const valueStateText = this.shouldDisplayDefaultValueStateMessage ? this.valueStateDefaultText : this.valueStateMessageText.map(el => el.textContent).join(" ");
const valueStateText = this.shouldDisplayDefaultValueStateMessage ? this.valueStateDefaultText : this.valueStateMessage.map(el => el.textContent).join(" ");

if (valueStateText) {
announce(valueStateText, InvisibleMessageMode.Polite);
Expand Down Expand Up @@ -1277,7 +1277,7 @@ class ComboBox extends UI5Element implements IFormInputElement {
return `${text} ${this.valueStateDefaultText || ""}`;
}

return `${text}`.concat(" ", this.valueStateMessageText.map(el => el.textContent).join(" "));
return `${text}`.concat(" ", this.valueStateMessage.map(el => el.textContent).join(" "));
}

get valueStateDefaultText(): string | undefined {
Expand All @@ -1288,10 +1288,6 @@ class ComboBox extends UI5Element implements IFormInputElement {
return this.valueStateTextMappings[this.valueState];
}

get valueStateMessageText(): Array<Node> {
return this.getSlottedNodes("valueStateMessage").map(el => el.cloneNode(true));
}

get valueStateTextMappings(): ValueStateAnnouncement {
return {
[ValueState.Positive]: ComboBox.i18nBundle.getText(VALUE_STATE_SUCCESS),
Expand Down
8 changes: 5 additions & 3 deletions packages/main/src/ComboBoxPopover.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
{{#if hasValueStateText}}
<div class="{{classes.popoverValueState}}" style="{{styles.popoverValueStateMessage}}">
<ui5-icon class="ui5-input-value-state-message-icon" name="{{_valueStateMessageIcon}}"></ui5-icon>
{{#if open}}
{{> valueStateMessage}}
{{/if}}
</div>
{{/if}}
{{/if}}
Expand All @@ -64,7 +66,9 @@
{{#if hasValueStateText}}
<div slot="header" class="ui5-responsive-popover-header {{classes.popoverValueState}}" ?focused={{_isValueStateFocused}} style="{{styles.suggestionPopoverHeader}}">
<ui5-icon class="ui5-input-value-state-message-icon" name="{{_valueStateMessageIcon}}"></ui5-icon>
{{#if open}}
{{> valueStateMessage}}
{{/if}}
</div>
{{/if}}
{{/unless}}
Expand Down Expand Up @@ -132,9 +136,7 @@
{{#if shouldDisplayDefaultValueStateMessage}}
{{valueStateDefaultText}}
{{else}}
{{#each valueStateMessageText}}
{{this}}
{{/each}}
<slot name="valueStateMessage"></slot>
{{/if}}
{{/inline}}

Expand Down
7 changes: 3 additions & 4 deletions packages/main/test/specs/ComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ describe("General interaction", () => {

// click on first item
const popover = await combo.shadow$("ui5-responsive-popover");
const link = await popover.$(".ui5-responsive-popover-header.ui5-valuestatemessage-root a");
const link = await combo.$("div[slot='valueStateMessage'] a");

await link.click();

Expand Down Expand Up @@ -912,8 +912,7 @@ describe("Accessibility", async () => {
await cbError.click();
await cbError.keys("a");

const popoverHeader = await cbError.shadow$("ui5-responsive-popover .ui5-valuestatemessage-header");
const valueStateText = await popoverHeader.$("div").getHTML(false);
const valueStateText = await cbError.$("div[slot='valueStateMessage']").getHTML(false);
const ariaHiddenText = await cbError.shadow$(`#value-state-description`).getHTML(false);

assert.strictEqual(ariaHiddenText.includes("Value State"), true, "Hidden screen reader text is correct");
Expand Down Expand Up @@ -1332,7 +1331,7 @@ describe("Keyboard navigation", async () => {

const valueState = await comboBox.shadow$("ui5-popover");

await valueState.$("a").click();
await comboBox.$("div[slot='valueStateMessage'] a").click();
await comboBox.keys("Tab");

assert.notOk(await valueState.isExisting(), "Value state message is closed.");
Expand Down

0 comments on commit a24c6b7

Please sign in to comment.