Skip to content

Commit 4b431fe

Browse files
devversionjelbourn
authored andcommittedNov 1, 2018
fix(button): stroked button crops applied badges (#13912)
Since we hide overflow for stroked buttons in order to properly handle the `border-radius` for the child ripple container and focus overlay, badges which are applied on the button will be clipped. In order to fix this bug, we just remove the `overflow: hidden` and go back to the initial implemenation where the border radius is inherited for the child elements. Just to keep #13738 resolved, we ensure that the child elements fully cover the actual button element for the _correct_ border radius. Fixes #13909
1 parent 28fb3ab commit 4b431fe

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed
 

‎src/demo-app/badge/badge-demo.html

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ <h3>Buttons</h3>
5252
<mat-icon color="primary">home</mat-icon>
5353
</button>
5454

55+
<button mat-stroked-button [matBadge]="badgeContent">
56+
<mat-icon color="primary">home</mat-icon>
57+
</button>
58+
5559
<button disabled mat-raised-button [matBadge]="badgeContent" matBadgeDisabled>
5660
<mat-icon color="primary">home</mat-icon>
5761
</button>

‎src/lib/button/_button-base.scss

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ $mat-button-focus-transition: opacity 200ms $swift-ease-in-out-timing-function,
1717
// button's padding.
1818
$mat-stroked-button-line-height: $mat-button-line-height - 2;
1919
$mat-stroked-button-padding: 0 15px;
20+
$mat-stroked-button-border-width: 1px;
2021

2122
// Icon Button standards
2223
$mat-icon-button-size: 40px !default;

‎src/lib/button/button.scss

+11-9
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,22 @@
4242
}
4343

4444
.mat-stroked-button {
45-
border: 1px solid currentColor;
45+
border: $mat-stroked-button-border-width solid currentColor;
4646
padding: $mat-stroked-button-padding;
4747
line-height: $mat-stroked-button-line-height;
4848

4949
// Since the stroked button has has an actual border that reduces the available space for
50-
// child elements (such as the ripple container or focus overlay), an inherited border radius
51-
// for absolute positioned child elements which expand to the parent element boundaries, will
52-
// not align with the stroked button border because the child element cannot expand to the same
53-
// boundaries as the parent element with a border.
54-
// See: https://github.com/angular/material2/issues/13738
55-
overflow: hidden;
56-
50+
// child elements such as the ripple container or focus overlay, an inherited border radius
51+
// for the absolute-positioned child elements does not work properly. This is because the
52+
// child element cannot expand to the same boundaries as the parent element with a border.
53+
// In order to work around this issue by *not* hiding overflow, we adjust the child elements
54+
// to fully cover the actual button element. This means that the border-radius would be correct
55+
// then. See: https://github.com/angular/material2/issues/13738
5756
.mat-button-ripple.mat-ripple, .mat-button-focus-overlay {
58-
border-radius: 0;
57+
top: -$mat-stroked-button-border-width;
58+
left: -$mat-stroked-button-border-width;
59+
right: -$mat-stroked-button-border-width;
60+
bottom: -$mat-stroked-button-border-width;
5961
}
6062
}
6163

0 commit comments

Comments
 (0)
Please sign in to comment.