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-comboBox): delete token from mcb with grouping #9623

Merged
merged 1 commit into from
Aug 6, 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
2 changes: 1 addition & 1 deletion packages/main/src/MultiComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ class MultiComboBox extends UI5Element implements IFormInputElement {
_tokenDelete(e: CustomEvent<TokenizerTokenDeleteEventDetail>) {
this._previouslySelectedItems = this._getSelectedItems();
const token: Token[] = e.detail.tokens;
const deletingItems = this.items.filter(item => token.some(t => t.getAttribute("data-ui5-id") === item._id));
const deletingItems = this._getItems().filter(item => token.some(t => t.getAttribute("data-ui5-id") === item._id));

deletingItems.forEach(item => {
item.selected = false;
Expand Down
28 changes: 28 additions & 0 deletions packages/main/test/specs/MultiComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,34 @@ describe("MultiComboBox general interaction", () => {
assert.strictEqual(tokens.length, 0, "Long token should be deleted" );
});

it("tests if clicking delete icon of a token removes it from the selection (mcb with grouping)", async () => {
await browser.url(`test/pages/MultiComboBox.html`);

const mcb = $("#mcb-grouping");
const inner = mcb.shadow$("input");

await mcb.scrollIntoView();
await inner.click();

await inner.keys("a");
const popover = await mcb.shadow$("ui5-responsive-popover");
const firstItem = await popover.$(".ui5-multi-combobox-all-items-list > ui5-li");
await firstItem.click();

let tokens = await mcb.shadow$$(".ui5-multi-combobox-token");

assert.strictEqual(tokens.length, 1, "Token should be added");

const token = await mcb.shadow$("ui5-tokenizer ui5-token");
const deleteIcon = await token.shadow$(".ui5-token--icon");

await deleteIcon.click();

tokens = await mcb.shadow$$(".ui5-multi-combobox-token");

assert.strictEqual(tokens.length, 0, "Token should be deleted");
});

it("prevents selection change event when clicking an item", async () => {
await browser.url(`test/pages/MultiComboBox.html`);

Expand Down