Skip to content

Commit 4bc8ba7

Browse files
authored
fix(ui5-file-uploader): adjust tokenizer collapse behaviour (#12250)
* fix(ui5-file-uploader): adjust tokenizer collapse behaviour Issue: - The ui5-tokenizer doesn't collapse when the n-More popover gets closed via mouse out.
1 parent 0944107 commit 4bc8ba7

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

packages/main/cypress/specs/FileUploader.cy.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,62 @@ describe("Interaction", () => {
419419
.find("[ui5-token]")
420420
.should("have.length", 1);
421421
});
422+
423+
it("tokenizer collapses when n-More popover loses focus", () => {
424+
cy.mount(
425+
<FileUploader id="uploader" style="width: 200px;"></FileUploader>
426+
);
427+
428+
cy.get("[ui5-file-uploader]")
429+
.as("uploader")
430+
.shadow()
431+
.find("input[type='file']")
432+
.selectFile([
433+
{
434+
contents: Cypress.Buffer.from("file1 content"),
435+
fileName: "file1.txt",
436+
mimeType: "text/plain"
437+
},
438+
{
439+
contents: Cypress.Buffer.from("file2 content"),
440+
fileName: "file11.txt",
441+
mimeType: "text/plain"
442+
},
443+
{
444+
contents: Cypress.Buffer.from("file3 content"),
445+
fileName: "file111.txt",
446+
mimeType: "text/plain"
447+
}
448+
], { force: true });
449+
450+
cy.get("@uploader")
451+
.shadow()
452+
.find("[ui5-tokenizer]")
453+
.as("tokenizer")
454+
.should("exist");
455+
456+
cy.get("@uploader").realClick();
457+
cy.get("@uploader").realPress("ArrowRight");
458+
459+
cy.focused()
460+
.should("have.attr", "aria-description", "Token");
461+
462+
cy.realPress(["Control", "i"]);
463+
464+
cy.get("@tokenizer")
465+
.shadow()
466+
.find("ui5-responsive-popover")
467+
.should("exist");
468+
469+
cy.get("@tokenizer")
470+
.should("have.attr", "expanded");
471+
472+
cy.get("body")
473+
.realClick();
474+
475+
cy.get("@tokenizer")
476+
.should("not.have.attr", "expanded");
477+
});
422478
});
423479

424480
describe("Accessibility", () => {

packages/main/src/FileUploader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ class FileUploader extends UI5Element implements IFormInputElement {
426426

427427
this.focused = false;
428428
if (this._tokenizer) {
429-
this._tokenizer.expanded = this._tokenizerOpen;
429+
this._tokenizer.expanded = this._tokenizer.open;
430430
}
431431
}
432432

@@ -667,7 +667,7 @@ class FileUploader extends UI5Element implements IFormInputElement {
667667
}
668668

669669
get shouldOpenValueStateMessagePopover(): boolean {
670-
return this.focused && this.hasValueState && !this.hideInput && !this._tokenizerOpen;
670+
return this.focused && this.hasValueState && !this.hideInput && !this._tokenizer?.open;
671671
}
672672

673673
/**

0 commit comments

Comments
 (0)