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 3 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, 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

size = BREADCRUMB_SIZE.MEDIUM;

/**
Expand Down Expand Up @@ -66,6 +66,18 @@ class CDSBreadcrumb extends LitElement {
`;
}

updated(changedProperties) {
if (changedProperties.has('size')) {
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

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

static styles = styles;
}

Expand Down
Loading