Skip to content

fix(material/chips): adds border on chip-action focus #30961

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
39 changes: 27 additions & 12 deletions src/material/chips/chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,35 @@ $token-slots: m2-chip.get-token-slots();
pointer-events: none;
}

}

// Targets .mdc-evolution-chip__cell
.mat-mdc-chip-action .mat-focus-indicator::before,
// Targets mdc-evolution-chip__icon
.mat-mdc-chip-action.mat-focus-indicator::before {
// For the chip element, default inset/offset values are necessary to ensure that
// the focus indicator is sufficiently contrastive and renders appropriately.
.mat-focus-indicator::before {
$default-border-width: focus-indicators-private.$default-border-width;
$border-width: var(--mat-focus-indicator-border-width, #{$default-border-width});
$offset: calc(#{$border-width} + 2px);
margin: calc(#{$offset} * -1);
}
$default-border-width: focus-indicators-private.$default-border-width;
$border-width: var(--mat-focus-indicator-border-width, #{$default-border-width});
$offset: calc(#{$border-width} + 2px);

content: '';
display: block;
position: absolute;
padding: $offset;
margin: calc(#{$offset} * -1);
border-width: $border-width;
border: solid;
border-color: var(--mat-focus-indicator-border-color), black;
opacity: 0;
height: auto;
}

// The chip has multiple focus targets so we have to put the indicator on
// a separate element, rather than on the focusable element itself.
.mat-mdc-chip-action:focus .mat-focus-indicator::before,
.mat-mdc-chip-action.mat-focus-indicator:focus::before {
opacity: 1;
}

.mat-mdc-chip-remove {
Expand Down Expand Up @@ -735,12 +756,6 @@ $token-slots: m2-chip.get-token-slots();
}
}

// The chip has multiple focus targets so we have to put the indicator on
// a separate element, rather than on the focusable element itself.
.mat-mdc-chip-action:focus .mat-focus-indicator::before {
content: '';
}

// Prevents icon from being cut off when text spacing is increased.
// .mat-mdc-chip-remove selector necessary for remove button with icon.
// Fixes b/250063405.
Expand Down
Loading