Skip to content

Commit cf61af5

Browse files
essjay05crisbeto
authored andcommitted
fix(material/chips): remove button is too small (#29351)
* fix(material/chip): remove button is too small Fixes Angular Components Chip component where the touch target of the remove button of a chip is too small. Updates .mat-mdc-chip-remove to target more specific styles to override original style of padding: 8px so that the user has a larger touch target particularly on mobile devices. Fixes b/286959517 * refactor(material/chips): remove button is too small Fixes lint errors from previous commit for Angular Components Chip component where the remove button touch target is too small, particularly for touch/mobile devices. Increases padding on all sides. Fixes b/286959517 * fix(material/chips): increase chip remove button touch target size Fixes issue with Angular Component Chip's touch target size by increasing the padding on chips with a trailing icon that has an action. Fixes b/286959517 BREAKING CHANGE: updates chip remove button touch target to increase accessibility of the button especially on touch/mobile devices. * refactor(material/chips): chip remove touch target size is insufficient Updates fix to Autocomplete Component Chips component where the touch target size is too small and fails minimum accessibility size of 48x48 px. Addresses nit fixes from PR review. Fixes b/286959517 BREAKING CHANGE: updates padding size of remove touch target to satisfy minimum 48x48 accessibility size. * fix(material/chip): remove button is too small Fixes Angular Components Chip component where the touch target of the remove button of a chip is too small. Updates .mat-mdc-chip-remove to target more specific styles to override original style of padding: 8px so that the user has a larger touch target particularly on mobile devices. Fixes b/286959517 * refactor(material/chips): remove button is too small Fixes lint errors from previous commit for Angular Components Chip component where the remove button touch target is too small, particularly for touch/mobile devices. Increases padding on all sides. Fixes b/286959517 * fix(material/chips): increase chip remove button touch target size Fixes issue with Angular Component Chip's touch target size by increasing the padding on chips with a trailing icon that has an action. Fixes b/286959517 BREAKING CHANGE: updates chip remove button touch target to increase accessibility of the button especially on touch/mobile devices. * fix(material/chips): chips remove touch target is too small to be accessible Updates Angular Components Chips component by increasing its .mat-mdc-chip-remove::after styles to increase the size of the touch target to make it more accessible/clickable. Fixes b/286959517 * refactor(material/chips): fix lint errors Updates fix for Angular Components Chips component where there were lint formatting errors. * refactor(material/chips): replace px with _trailing-icon-size variable Updates previous Angular Components Chip component fix and makes it adaptable by swapping the hard-coded 18px offset to equal the variable for -icon-size. * refactor(material/chips): updates touch target centering method Updates previous Angular Component Chip component fix which added padding to the ::after pseudo-element and attempted to calculate centering. Changes calculation based on using with padding values countered with margin negative values to center the touch target. * refactor(material/chips): updates ::after styles and fix lint errors Updates Angular Component Chips component fix to change ::after background property changes to be background-color specifically to avoid overriding background-clip styles. Suppresses lint warning material/no-prefixes for background-clip since it's majority compatible with browsers. Fixes b/286959517 (cherry picked from commit d6aed80)
1 parent cae52de commit cf61af5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/material/chips/chip.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ $_avatar-trailing-padding: 8px;
538538
}
539539

540540
&::after {
541-
@include token-utils.create-token-slot(background, trailing-action-state-layer-color);
541+
@include token-utils.create-token-slot(background-color, trailing-action-state-layer-color);
542542
}
543543

544544
&:hover::after {
@@ -552,7 +552,8 @@ $_avatar-trailing-padding: 8px;
552552

553553
.mat-mdc-chip-selected .mat-mdc-chip-remove::after,
554554
.mat-mdc-chip-highlighted .mat-mdc-chip-remove::after {
555-
@include token-utils.create-token-slot(background, selected-trailing-action-state-layer-color);
555+
@include token-utils.create-token-slot(background-color,
556+
selected-trailing-action-state-layer-color);
556557
}
557558
}
558559

@@ -695,7 +696,9 @@ $_avatar-trailing-padding: 8px;
695696

696697
// Used as a state overlay.
697698
&::after {
698-
$offset: 2px;
699+
$_touch-target-size: 48px;
700+
$_ripple-size: 24px;
701+
$offset: 3px;
699702
content: '';
700703
display: block;
701704
opacity: 0;
@@ -705,6 +708,11 @@ $_avatar-trailing-padding: 8px;
705708
left: 8px - $offset;
706709
right: 8px - $offset;
707710
border-radius: 50%;
711+
box-sizing: border-box;
712+
padding: calc(($_touch-target-size - $_ripple-size)/2);
713+
margin: calc((($_touch-target-size - $_ripple-size)/2) * -1);
714+
// stylelint-disable material/no-prefixes
715+
background-clip: content-box;
708716
}
709717

710718
.mat-icon {

0 commit comments

Comments
 (0)