Skip to content

fix: breadcrumb with single character fails wcag 2.2 target size #19287

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

Conversation

preetibansalui
Copy link
Contributor

@preetibansalui preetibansalui commented May 2, 2025

Closes #19266

Breadcrumb with single character in small size fails to wcag 2.2 target size, it should be minimum 24 px.

Changelog

Changed

Provide a minimum width of 20px to breadcrumb item

Testing / Reviewing

  1. Go to Storybook > Breadcrumb > Default
  2. change text to single corrector, eg: 1,2
  3. Inspect and check the size, it's width should be more than 24px including margins.

@preetibansalui preetibansalui requested review from a team as code owners May 2, 2025 13:38
Copy link

netlify bot commented May 2, 2025

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

Name Link
🔨 Latest commit d58a885
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/681cd1e5a65e930007176244
😎 Deploy Preview https://deploy-preview-19287--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 site configuration.

Copy link

netlify bot commented May 2, 2025

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit d58a885
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/681cd1e5a37e8b000707a774
😎 Deploy Preview https://deploy-preview-19287--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 site configuration.

Copy link

codecov bot commented May 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.78%. Comparing base (42d3f0b) to head (d58a885).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19287   +/-   ##
=======================================
  Coverage   84.78%   84.78%           
=======================================
  Files         371      371           
  Lines       14411    14411           
  Branches     4713     4747   +34     
=======================================
  Hits        12218    12218           
  Misses       2044     2044           
  Partials      149      149           

☔ 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.

@@ -49,6 +49,11 @@
margin-inline-end: $spacing-02;
}

.#{$prefix}--breadcrumb--sm .#{$prefix}--breadcrumb-item .#{$prefix}--link {
justify-content: center;
min-inline-size: $spacing-04;
Copy link
Member

@annawen1 annawen1 May 2, 2025

Choose a reason for hiding this comment

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

@warrenmblood had mentioned this issue with the Target size doesn't exist in Web Components because the margin is 8px instead of 4px in React - I wonder if we need to discuss with design to see if it's just an issue of adjusting the margins? or if this fix needs to be applied to WC too (setting the margin to 4px to align with React and then applying this same fix)?

Screenshot 2025-05-02 at 10 18 40 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought to avoid changing the margins because it would affect all breadcrumbs, not just the single-character ones, which could potentially break the existing design for current users. I think it's a good idea to confirm with Design.

Copy link
Contributor

@warrenmblood warrenmblood left a comment

Choose a reason for hiding this comment

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

I agree with discussing this with design first and deciding how to match WC and React, but these changes look good to me for preventing the WCAG target size failure!

@thyhmdo
Copy link
Member

thyhmdo commented May 5, 2025

Hi, according to our guidance:

  • 4px/.25rem is applied to margins of the small size
  • 8px/.5 rem is applied to margins of the medium size

image
image

@preetibansalui
Copy link
Contributor Author

Hi, according to our guidance:

  • 4px/.25rem is applied to margins of the small size
  • 8px/.5 rem is applied to margins of the medium size

image image

Thanks @thyhmdo !

@annawen1 : Small and medium breadcrumbs already have guided margins, so the minimum width solution should be fine.

@annawen1
Copy link
Member

annawen1 commented May 6, 2025

Hi, according to our guidance:

  • 4px/.25rem is applied to margins of the small size
  • 8px/.5 rem is applied to margins of the medium size

image image

Thanks @thyhmdo !

@annawen1 : Small and medium breadcrumbs already have guided margins, so the minimum width solution should be fine.

Ok great, let's adjust the margin on WC small breadcrumb since it's currently 8px and confirm the min-width also gets applied there too!

@preetibansalui
Copy link
Contributor Author

Hi, according to our guidance:

  • 4px/.25rem is applied to margins of the small size
  • 8px/.5 rem is applied to margins of the medium size

image image

Thanks @thyhmdo !
@annawen1 : Small and medium breadcrumbs already have guided margins, so the minimum width solution should be fine.

Ok great, let's adjust the margin on WC small breadcrumb since it's currently 8px and confirm the min-width also gets applied there too!

Applied the same changes to web-components as well to make them align. Please review

Comment on lines 71 to 73
const items = document
.querySelector(`${prefix}-breadcrumb`)
?.querySelectorAll(`${prefix}-breadcrumb-item`);
Copy link
Member

@annawen1 annawen1 May 7, 2025

Choose a reason for hiding this comment

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

Suggested change
const items = document
.querySelector(`${prefix}-breadcrumb`)
?.querySelectorAll(`${prefix}-breadcrumb-item`);
const items = this.querySelectorAll(`${prefix}-breadcrumb-item`);

You'll want to scope the querySelector to the current instance of breadcrumb instead of document otherwise if there are other instances of breadcrumb on the page, it will affect those other instances as well

@@ -29,7 +29,7 @@ class CDSBreadcrumb extends LitElement {
* Specify the size of the Breadcrumb. Currently
* supports the following: `sm` & `md` (default: 'md')
*/
@property()
@property({ type: BREADCRUMB_SIZE, reflect: true, attribute: 'size' })
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@property({ type: BREADCRUMB_SIZE, reflect: true, attribute: 'size' })
@property({ type: BREADCRUMB_SIZE, reflect: true })

Also no need to set the attribute here since the name is the same

Copy link
Contributor

@warrenmblood warrenmblood left a comment

Choose a reason for hiding this comment

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

LGTM

@warrenmblood warrenmblood added this pull request to the merge queue May 8, 2025
Merged via the queue into carbon-design-system:main with commit 990010d May 8, 2025
37 checks passed
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.

[a11y]: Breadcrumb with single-character link names fails WCAG 2.2 target size
4 participants