Skip to content

fix: address accessibility for pagination and select#21942

Merged
maradwan26 merged 21 commits into
carbon-design-system:mainfrom
davidmenendez:issue-21932
Apr 20, 2026
Merged

fix: address accessibility for pagination and select#21942
maradwan26 merged 21 commits into
carbon-design-system:mainfrom
davidmenendez:issue-21932

Conversation

@davidmenendez

@davidmenendez davidmenendez commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Closes #21932

Resolves accessibility violations from the cds-pagination web-component

Screenshot 2026-04-01 at 3 49 11 PM

Changelog

New

  • added the label-styles-disable prop to the cds-select web-component to account for use-cases where the user doesn't want the label to use the default cds--label class & styles

Changed

  • in cds-pagination the default value for itemsPerPageText has been removed
  • in cds-pagination the label elements adjacent to the cds-select components were moved to use the label-text slots in cds-select
  • in cds-select the id prop now has no default value and is appropriately applied to the underlying label and select elements. prior to this it was just using the hardcoded value of input

Testing / Reviewing

  • verify yarn test passes
  • verify that the pagination component has no violations in the accessibility tab in storybook

PR Checklist

As the author of this PR, before marking ready for review, confirm you:

  • Reviewed every line of the diff
  • Updated documentation and storybook examples
  • Wrote passing tests that cover this change
  • Addressed any impact on accessibility (a11y)
  • Tested for cross-browser consistency
  • Validated that this code is ready for review and status checks should pass

More details can be found in the pull request guide

@davidmenendez davidmenendez requested a review from a team as a code owner April 1, 2026 21:07
@codecov

codecov Bot commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.89%. Comparing base (27f2292) to head (69b9e8a).
⚠️ Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21942      +/-   ##
==========================================
- Coverage   94.89%   94.89%   -0.01%     
==========================================
  Files         539      539              
  Lines       45015    45019       +4     
  Branches     6352     6351       -1     
==========================================
+ Hits        42716    42719       +3     
- Misses       2167     2168       +1     
  Partials      132      132              
Flag Coverage Δ
main-packages 88.99% <ø> (ø)
web-components 97.70% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@netlify

netlify Bot commented Apr 1, 2026

Copy link
Copy Markdown

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 69b9e8a
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/69df8b72a570cc0008346d57
😎 Deploy Preview https://deploy-preview-21942--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Apr 1, 2026

Copy link
Copy Markdown

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 69b9e8a
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/69df8b72ca84e80008518610
😎 Deploy Preview https://deploy-preview-21942--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@davidmenendez

Copy link
Copy Markdown
Contributor Author

testing is passing locally, but i'm dumb and forgot you have to rebuild before retesting to test the latest changes 😂

i will fix those tests ASAP

Comment thread packages/web-components/src/components/pagination/pagination.ts Outdated
Comment thread packages/web-components/src/components/select/select.ts

@maradwan26 maradwan26 left a comment

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.

LGTM!

Comment thread packages/web-components/src/components/select/select.ts Outdated
Comment thread packages/web-components/src/components/pagination/pagination.ts Outdated
Comment thread packages/web-components/src/components/pagination/pagination.ts Outdated
@adamalston

Copy link
Copy Markdown
Contributor

The pull request template is incomplete.

@davidmenendez

Copy link
Copy Markdown
Contributor Author

@adamalston updated

  • added missing id attribute to select components and stories
  • added test to pagination to test case when no label is supplied
  • added test to select to test case when no id is supplied

@davidmenendez

Copy link
Copy Markdown
Contributor Author

I've been thinking about the id concern. looking across the web-components package and there are numerous places where the id attribute is set as a prop but not set to be required, are given a default value id = 'checkbox'; // checkbox.ts, or are set to '' and not even used like in textarea.ts

I agree that this should be fixed and understand it may be a breaking change. If that's the case then this may be something we want to sort out in a separate issue and PR. For the sake of this PR, it might be easier to omit the changes associated with removing the default id value and address it separately.

Thoughts?

@adamalston

Copy link
Copy Markdown
Contributor

I think that sounds reasonable. Once an approach is finalized, maybe it could be standardized.

@davidmenendez

Copy link
Copy Markdown
Contributor Author

changes made 👍

@davidmenendez

Copy link
Copy Markdown
Contributor Author

would love to get this merged in ASAP if someone can take a look. thanks! 👍

Comment thread packages/web-components/src/components/select/select.mdx Outdated
*/
@property()
id = '';
id = 'input';

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.

I think #21942 (comment) was addressed. However, some changes were later reverted, understandably, and the issue now appears to have resurfaced.

Does anything need to be updated? My understanding of the current implementation is that unless each consumer overrides this id, it may lead to duplicate values. That could cause problems with selectors and ARIA references.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

based on my understanding of how the shadow dom works, i think it's technically ok due to the encapsulation that web components provide. it's probably still best for users to implement their own select components with unique ids, but i don't think it will actually cause issue to use the same id in different shadow roots.

it's not flagged as an issue by the accessibility checker in the pagination component when both of the select ids are removed

Screenshot 2026-04-14 at 2 40 19 PM

since this is a preexisting implementation i think it would be better to discuss further in a separate issue 👍

sources:

*/
@property({ attribute: 'items-per-page-text' })
itemsPerPageText = 'Items per page:';
itemsPerPageText = '';

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.

Should this prop be marked as required now that it's not set by default?

expect(label?.textContent?.trim()).to.equal('éléments par page');
});

it('should respect items-per-page-text attribute when not supplied', async () => {

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.

Suggested change
it('should respect items-per-page-text attribute when not supplied', async () => {
it('should default to an empty label when `items-per-page-text` is omitted', async () => {

@maradwan26 maradwan26 added this pull request to the merge queue Apr 20, 2026
Merged via the queue into carbon-design-system:main with commit 19e73c0 Apr 20, 2026
39 checks passed
MarianaAa01 pushed a commit to MarianaAa01/carbon that referenced this pull request May 29, 2026
…ystem#21942)

* fix: address accessibility for pagination and select

* fix: update select wc story

* fix: tests

* fix: resolve input and select query

* fix: minor label margin style

* fix: add label slot back into pagination

* fix: tests

* fix: added missing select ids and testing

* fix: remove only from test

* fix: add default id back in select

* fix: react tests

* fix: react tests

* fix: docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[a11y]: Resolve accessibility issues in the Pagination component

4 participants