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): fix aria-describedby token count #9888

Merged
merged 2 commits into from
Sep 19, 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
5 changes: 1 addition & 4 deletions packages/main/src/MultiComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ class MultiComboBox extends UI5Element implements IFormInputElement {
_isOpenedByKeyboard?: boolean;
_itemToFocus?: IMultiComboBoxItem;
_itemsBeforeOpen: Array<MultiComboboxItemWithSelection>;
_tokenCount: number | undefined;
selectedItems: Array<IMultiComboBoxItem>;
static i18nBundle: I18nBundle;

Expand Down Expand Up @@ -707,7 +706,6 @@ class MultiComboBox extends UI5Element implements IFormInputElement {
}

_tokenDelete(e: CustomEvent<TokenizerTokenDeleteEventDetail>) {
this._tokenCount = this._tokenizer.tokens.length - e.detail.tokens.length;
this._previouslySelectedItems = this._getSelectedItems();
const token: Token[] = e.detail.tokens;
const deletingItems = this._getItems().filter(item => token.some(t => t.getAttribute("data-ui5-id") === item._id));
Expand Down Expand Up @@ -1894,8 +1892,7 @@ class MultiComboBox extends UI5Element implements IFormInputElement {
return;
}

this._tokenCount = this._tokenCount !== undefined ? this._tokenCount : this._tokenizer.tokens.length;
return getTokensCountText(this._tokenCount);
return getTokensCountText(this.selectedValues.length);
}

get _tokensCountTextId() {
Expand Down
13 changes: 13 additions & 0 deletions packages/main/test/specs/MultiComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,8 @@ describe("MultiComboBox general interaction", () => {
const innerInput = await mcb.shadow$("input");
let invisibleText = await mcb.shadow$(".ui5-hidden-text");
const inivisbleTextId = await invisibleText.getProperty("id");
const popover = await mcb.shadow$("ui5-responsive-popover");
let firstItem = await popover.$("ui5-list").$("ui5-li");
let tokens = await mcb.shadow$$(".ui5-multi-combobox-token");
let resourceBundleText = null;

Expand Down Expand Up @@ -1793,6 +1795,17 @@ describe("MultiComboBox general interaction", () => {

assert.strictEqual(tokens.length, 0, "should not have tokens");
assert.ok(await ariaHiddenText.includes(resourceBundleText), "aria-describedby text is correct");

await innerInput.click();
await innerInput.keys("i");
await firstItem.click();

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

assert.strictEqual(tokens.length, 1, "Token should be added");
assert.ok(await ariaHiddenText.includes("Contains 1 token"), "aria-describedby text is correct after adding token again");

});

it("Should apply aria-label from the accessibleName property", async () => {
Expand Down