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

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: 5 additions & 0 deletions packages/styles/scss/components/breadcrumb/_breadcrumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}

.#{$prefix}--breadcrumb-item .#{$prefix}--link:visited {
color: $link-primary;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ $css--plex: true !default;
display: none;
}
}
:host(#{$prefix}-breadcrumb-link[size='sm']) {
min-inline-size: $spacing-04;
text-align: center;
}

:host(#{$prefix}-breadcrumb-link[aria-current='page']) .#{$prefix}--link {
color: $text-primary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
size = BREADCRUMB_SIZE.MEDIUM;

/**
Expand All @@ -53,6 +53,16 @@ class CDSBreadcrumb extends LitElement {
super.connectedCallback();
}

updated(changedProperties) {
if (changedProperties.has('size')) {
const items = this.querySelectorAll(`${prefix}-breadcrumb-item`);
items?.forEach((item) => {
const link = item.querySelector(`${prefix}-breadcrumb-link`);
link?.setAttribute('size', this.size);
});
}
}

render() {
const classes = classMap({
[`${prefix}--breadcrumb`]: true,
Expand Down
Loading