Skip to content

feat: Add vocalization of dropdown item count#21286

Merged
BenjaminEmiliani merged 12 commits intodevelopfrom
fix/CXSPA-12456-vocalize_list_item_count
Apr 1, 2026
Merged

feat: Add vocalization of dropdown item count#21286
BenjaminEmiliani merged 12 commits intodevelopfrom
fix/CXSPA-12456-vocalize_list_item_count

Conversation

@BenjaminEmiliani
Copy link
Copy Markdown
Member

@BenjaminEmiliani BenjaminEmiliani commented Mar 26, 2026

Tested and validated on iOS 26.4 - iPhone 17. Behaviour is almost identical to what is observed on mac Voice Over.

@BenjaminEmiliani BenjaminEmiliani requested a review from a team as a code owner March 26, 2026 14:16
@github-actions github-actions Bot marked this pull request as draft March 26, 2026 14:16
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review March 26, 2026 14:16
@cypress
Copy link
Copy Markdown

cypress Bot commented Mar 26, 2026

spartacus    Run #52562

Run Properties:  status check passed Passed #52562  •  git commit 5c3d28501d ℹ️: Merge 8f59b0532d203e5543bb914f6a5cc4c8fa41c7fa into 1b95711df69929ab3dba4aedf184...
Project spartacus
Branch Review fix/CXSPA-12456-vocalize_list_item_count
Run status status check passed Passed #52562
Run duration 04m 15s
Commit git commit 5c3d28501d ℹ️: Merge 8f59b0532d203e5543bb914f6a5cc4c8fa41c7fa into 1b95711df69929ab3dba4aedf184...
Committer Benjamin Emiliani
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 3
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 101
View all changes introduced in this branch ↗︎

@github-actions github-actions Bot marked this pull request as draft March 26, 2026 17:58
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review March 30, 2026 20:14
@github-actions github-actions Bot marked this pull request as draft March 30, 2026 20:14
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review March 30, 2026 20:14
@github-actions
Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions Bot marked this pull request as draft March 31, 2026 14:21
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review March 31, 2026 17:57
@github-actions
Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions Bot marked this pull request as draft March 31, 2026 17:57
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review March 31, 2026 17:58
@github-actions
Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions Bot marked this pull request as draft March 31, 2026 18:12
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review March 31, 2026 18:12
) {
useFeatureStyles('a11yNgSelectUnicodeCarets');
if (this.featureConfigService.isEnabled('a11yVocalizeDropdownItemCount')) {
effect(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new method and move this logic into it, and call it in the constructor.
It will allow overraidabilty

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +92 to +116
if (!itemCountSpan) {
itemCountSpan = this.renderer.createElement('span');
this.renderer.addClass(itemCountSpan, 'cx-ng-select-count');
this.renderer.addClass(itemCountSpan, 'cx-visually-hidden');
this.renderer.setAttribute(itemCountSpan, ARIA_HIDDEN, 'true');
this.renderer.appendChild(
this.elementRef.nativeElement,
itemCountSpan
);
const countId =
(this.elementRef.nativeElement.id || 'ng-select') + '-count';
this.renderer.setAttribute(itemCountSpan, 'id', countId);
const inputCombobox =
this.elementRef.nativeElement.querySelector(
'[role="combobox"]'
);
if (inputCombobox) {
this.renderer.setAttribute(
inputCombobox,
'aria-describedby',
countId
);
}
this.destroyRef.onDestroy(() => itemCountSpan.remove());
}
Copy link
Copy Markdown
Contributor

@Pucek9 Pucek9 Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo woth to separate into another method:

  protected createItemCountSpan() {
    const itemCountSpan = this.renderer.createElement('span');
    this.renderer.addClass(itemCountSpan, 'cx-ng-select-count');
    this.renderer.addClass(itemCountSpan, 'cx-visually-hidden');
    this.renderer.setAttribute(itemCountSpan, ARIA_HIDDEN, 'true');
    this.renderer.appendChild(this.elementRef.nativeElement, itemCountSpan);
    const countId =
      (this.elementRef.nativeElement.id || 'ng-select') + '-count';
    this.renderer.setAttribute(itemCountSpan, 'id', countId);
    const inputCombobox =
      this.elementRef.nativeElement.querySelector('[role="combobox"]');
    if (inputCombobox) {
      this.renderer.setAttribute(inputCombobox, 'aria-describedby', countId);
    }
    this.destroyRef.onDestroy(() => itemCountSpan.remove());
    return itemCountSpan;
  }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +89 to +91
let itemCountSpan = this.elementRef.nativeElement.querySelector(
'.cx-ng-select-count'
);
Copy link
Copy Markdown
Contributor

@Pucek9 Pucek9 Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we can simplify

Suggested change
let itemCountSpan = this.elementRef.nativeElement.querySelector(
'.cx-ng-select-count'
);
const itemCountSpan = this.elementRef.nativeElement.querySelector(
'.cx-ng-select-count'
) ?? createItemCountSpan();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread nx.json
Comment on lines +251 to +252
"ngSelectDropdownCount": "{{count}} option available",
"ngSelectDropdownCount_other": "{{count}} options available"
Copy link
Copy Markdown
Contributor

@Pucek9 Pucek9 Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ngSelectDropdownOptionsList

@uroslates I can see you introduced it year ago and Ben would like to continue this semantic.
Is it some new customary to include the library name in the translation key? Is there a reason for that?

Suggested change
"ngSelectDropdownCount": "{{count}} option available",
"ngSelectDropdownCount_other": "{{count}} options available"
"dropdownCount": "{{count}} option available",
"dropdownCount_other": "{{count}} options available"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason I can think of is clarity

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to dropdownItemCount

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the reason was clarity because at that time the lib did not support customisation for these kind of customization. Later they introduced the config for controlling this. I think its good that you've renamed it.

@github-actions github-actions Bot marked this pull request as draft April 1, 2026 15:30
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review April 1, 2026 16:01
@github-actions github-actions Bot marked this pull request as draft April 1, 2026 16:01
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review April 1, 2026 16:01
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

private elementRef: ElementRef
) {
useFeatureStyles('a11yNgSelectUnicodeCarets');
this.vocalizeItemCount();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer ratcher

Suggested change
this.vocalizeItemCount();
if (this.featureConfigService.isEnabled('a11yVocalizeDropdownItemCount')) {
this.vocalizeItemCount();
}

what do you think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree - Done

@github-actions github-actions Bot marked this pull request as draft April 1, 2026 16:32
@BenjaminEmiliani BenjaminEmiliani marked this pull request as ready for review April 1, 2026 16:40
@BenjaminEmiliani BenjaminEmiliani merged commit 27552db into develop Apr 1, 2026
39 checks passed
@BenjaminEmiliani BenjaminEmiliani deleted the fix/CXSPA-12456-vocalize_list_item_count branch April 1, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants