Skip to content
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

fix(button): ripples blocking mouse events on user content #4526

Merged
merged 2 commits into from
May 15, 2017
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions src/lib/button/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
[class.mat-button-ripple-round]="_isRoundButton || _isIconButton"
[mdRippleCentered]="_isIconButton"
[mdRippleTrigger]="_getHostElement()"></div>
<!-- the touchstart handler prevents the overlay from capturing the initial tap on touch devices -->
<div class="mat-button-focus-overlay" (touchstart)="$event.preventDefault()"></div>
<div class="mat-button-focus-overlay"></div>
10 changes: 6 additions & 4 deletions src/lib/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@
left: 0;
bottom: 0;
right: 0;

// Disable pointer events for the ripple container and focus overlay because the container
// will overlay the user content and we don't want to disable mouse events on the user content.
// Pointer events can be safely disabled because the ripple trigger element is the host element.
pointer-events: none;
}

// Overlay to be used as a tint. Note that the same effect can be achieved by using a pseudo
// element, however we use a proper DOM element in order to be able to disable the default
// touch action. This makes the buttons more responsive on touch devices.
// Element that overlays the button to show focus and hover effects.
.mat-button-focus-overlay {
// The button spec calls for focus on raised buttons (and FABs) to be indicated with a
// black, 12% opacity shade over the normal color (for both light and dark themes).
background-color: rgba(black, 0.12);
border-radius: inherit;
pointer-events: none;
opacity: 0;

transition: $mat-button-focus-transition;
Expand Down