Skip to content

Commit

Permalink
fix(ui5-multi-combobox): fix aria-describedby token count (#9792)
Browse files Browse the repository at this point in the history
* fix(ui5-multi-combobox): adjust the failing aria-describedby test

the test is fixed to focus out the tested ui5-multi-combobox
in order for the aria-describedby attribute to be updated
  • Loading branch information
ndeshev authored Sep 13, 2024
1 parent bf1ede7 commit 2e0aa03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/main/src/MultiComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ 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 @@ -706,6 +707,7 @@ 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 @@ -1891,7 +1893,9 @@ class MultiComboBox extends UI5Element implements IFormInputElement {
if (!this._tokenizer) {
return;
}
return getTokensCountText(this._tokenizer.tokens.length);

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

get _tokensCountTextId() {
Expand Down
3 changes: 1 addition & 2 deletions packages/main/test/specs/MultiComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ describe("MultiComboBox general interaction", () => {
assert.strictEqual(await innerInput.getAttribute("aria-describedby"), ariaDescribedBy, "aria-describedby has a reference for the value state and the tokens count");
});

it.skip("aria-describedby value according to the tokens count", async () => {
it("aria-describedby value according to the tokens count", async () => {
const mcb = await browser.$("#mcb-compact");

await mcb.scrollIntoView();
Expand Down Expand Up @@ -1780,7 +1780,6 @@ describe("MultiComboBox general interaction", () => {
assert.ok(await ariaHiddenText.includes(resourceBundleText), "aria-describedby text is correct");

await innerInput.keys("Backspace");
await innerInput.keys("Tab");

tokens = await mcb.shadow$$(".ui5-multi-combobox-token");
invisibleText = await mcb.shadow$(".ui5-hidden-text");
Expand Down

0 comments on commit 2e0aa03

Please sign in to comment.