Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-combobox): remove the cloning of the value state message #9384

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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