Skip to content

Commit c4b3625

Browse files
devversionjelbourn
authored andcommitted
fix(list, option): ripples disable mouse events on user content (#4503)
Currently when a user places an element, that changes its color on hover, inside of a `md-option` or `md-list-item` the hover effect will never occur. This is because the ripples are overlying the user content and all pointer events are blocked accidentally. Fixes #4480
1 parent 2d551e9 commit c4b3625

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/lib/core/option/_option.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
bottom: 0;
2727
right: 0;
2828

29+
// Disable pointer events for the ripple container because the container will overlay the
30+
// user content and we don't want to disable mouse events on the user content.
31+
// Pointer events can be safely disabled because the ripple trigger element is the host element.
32+
pointer-events: none;
33+
2934
// In high contrast mode this completely covers the text.
3035
@include cdk-high-contrast {
3136
opacity: 0.5;

src/lib/list/list-item.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<div class="mat-list-item-content" [class.mat-list-item-focus]="_hasFocus">
2-
<div class="mat-list-item-ripple" md-ripple [mdRippleDisabled]="!isRippleEnabled()"></div>
2+
<div class="mat-list-item-ripple" md-ripple
3+
[mdRippleTrigger]="_getHostElement()"
4+
[mdRippleDisabled]="!isRippleEnabled()">
5+
</div>
6+
37
<ng-content
48
select="[md-list-avatar],[md-list-icon], [mat-list-avatar], [mat-list-icon]"></ng-content>
59
<div class="mat-list-text"><ng-content select="[md-line], [mat-line]"></ng-content></div>

src/lib/list/list.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ $mat-dense-list-icon-size: 20px;
5454
top: 0;
5555
right: 0;
5656
bottom: 0;
57+
58+
// Disable pointer events for the ripple container because the container will overlay the
59+
// user content and we don't want to disable mouse events on the user content.
60+
// Pointer events can be safely disabled because the ripple trigger element is the host element.
61+
pointer-events: none;
5762
}
5863

5964
&.mat-list-item-avatar .mat-list-item-content {

src/lib/list/list.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,9 @@ export class MdListItem implements AfterContentInit {
172172
_handleBlur() {
173173
this._hasFocus = false;
174174
}
175+
176+
/** Retrieves the DOM element of the component host. */
177+
_getHostElement(): HTMLElement {
178+
return this._element.nativeElement;
179+
}
175180
}

0 commit comments

Comments
 (0)