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-multi-input): prevent double value state message on nMore open #8638

Merged
merged 4 commits into from
Apr 5, 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
4 changes: 4 additions & 0 deletions packages/main/src/MultiInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ class MultiInput extends Input {

return this;
}

get shouldDisplayOnlyValueStateMessage() {
return this.hasValueStateMessage && !this.readonly && !this.open && this.focused && !this.tokenizer._isOpen;
}
}

MultiInput.define();
Expand Down
4 changes: 4 additions & 0 deletions packages/main/src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class Tokenizer extends UI5Element {
_itemNav: ItemNavigation;
_scrollEnablement: ScrollEnablement;
_expandedScrollWidth?: number;
_isOpen: boolean;

_handleResize() {
this._nMoreCount = this.overflownTokens.length;
Expand All @@ -189,6 +190,7 @@ class Tokenizer extends UI5Element {
});

this._scrollEnablement = new ScrollEnablement(this);
this._isOpen = false;
}

onBeforeRendering() {
Expand Down Expand Up @@ -221,6 +223,7 @@ class Tokenizer extends UI5Element {

async openMorePopover() {
(await this.getPopover()).showAt(this.morePopoverOpener || this);
this._isOpen = true;
}

_getTokens() {
Expand Down Expand Up @@ -617,6 +620,7 @@ class Tokenizer extends UI5Element {

async closeMorePopover() {
(await this.getPopover()).close(false, false, true);
this._isOpen = false;
}

get _nMoreText() {
Expand Down
15 changes: 15 additions & 0 deletions packages/main/test/specs/MultiInput.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,21 @@ describe("Keyboard handling", () => {
assert.strictEqual(await mi.getProperty("valueState"), "None", "Value state is None");
});

it("value state message popup should be closed when nMore popover is open", async () => {
const mi = await $("#multiInput-error");
const inner = await mi.shadow$("input");
const staticAreaItemClassName = await browser.getStaticAreaItemClassName("#multiInput-error");
const popover = await browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-popover");

await mi.scrollIntoView();

// populate new token
await inner.click();
await inner.keys(["Control", "i"]);

assert.strictEqual(await popover.getProperty("opened"), false, "Value state popup is closed");
});

it("should open popover on keyboard combination ctrl + i", async () => {
const mi = await $("#truncated-token");
const rpoClassName = await getTokenizerPopoverId("truncated-token");
Expand Down