Skip to content

Commit cc10807

Browse files
committed
fix(button): ripples blocking mouse events on user content
* The ripple overlay intercepts all mouse events on the user content and therefore users are not able to have interactive elements in their buttons. Normally buttons should not contain interactive elements inside, but since the fix is very easy it wouldn't hurt fixing it. * Removing the `(touchstart)` event that should prevent initial clicks because it didn't do anything (because of pointer-events: none) and the initial click doesn't seem to happen anymore. Related to angular#4503
1 parent 6121fa1 commit cc10807

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/lib/button/button.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
[class.mat-button-ripple-round]="_isRoundButton || _isIconButton"
44
[mdRippleCentered]="_isIconButton"
55
[mdRippleTrigger]="_getHostElement()"></div>
6-
<!-- the touchstart handler prevents the overlay from capturing the initial tap on touch devices -->
7-
<div class="mat-button-focus-overlay" (touchstart)="$event.preventDefault()"></div>
6+
<div class="mat-button-focus-overlay"></div>

src/lib/button/button.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
left: 0;
6565
bottom: 0;
6666
right: 0;
67+
68+
// Disable pointer events for the ripple container and focus overlay because the container
69+
// will overlay the user content and we don't want to disable mouse events on the user content.
70+
// Pointer events can be safely disabled because the ripple trigger element is the host element.
71+
pointer-events: none;
6772
}
6873

6974
// Overlay to be used as a tint. Note that the same effect can be achieved by using a pseudo
@@ -74,7 +79,6 @@
7479
// black, 12% opacity shade over the normal color (for both light and dark themes).
7580
background-color: rgba(black, 0.12);
7681
border-radius: inherit;
77-
pointer-events: none;
7882
opacity: 0;
7983

8084
transition: $mat-button-focus-transition;

0 commit comments

Comments
 (0)