angular / angular/components

bug(MatRipple): MatRipple can not be disabled for child components

Open
#29,133 4 comments 4 reactions 0 assignees View on GitHub
area: material/core P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

14

### Description

I once opened this issue (https://github.com/angular/components/issues/26656) and now coming back with another real-world-issue, that can't be solved neatly.

I have a selection with a ripple effect (the boxes in the screenshot) and some, optional, sub-options:

![image](https://github.com/angular/components/assets/38611461/c17c3445-cb64-49d5-b183-2cccbd6ca555)

Now every time I hit a suboption the box' ripple effect shows up. Disabling it only on inner click and re-enabling it seams like some nasty timing problem (and even looks like [ripple gets removed on mouse down etc.]).

In my opinion there **really** is a need to be able to disabler the ripple effect for some boxes inside the ripple container. There should either be a directive for disabling it or to make things easy, like I suggested in my previous post, be able to switch from `capture` to `bubbling` so it can be disabled the _vanilla Javascript way_ (`stopPropagation`).

### Reproduction

https://stackblitz.com/edit/angular-phk79p-fyt248

### Expected Behavior

Ripple should not show up on clicking some container's child elements.

### Actual Behavior

Ripple cannot be disabled for some inner clicks.

### Environment

- Angular: 18.0.1
- CDK/Material: 18.0.0

Contributor guide

Open the contributing guide

Research direction

Reproduce the nested-click behavior in the linked StackBlitz using Angular 18.0.1 and CDK/Material 18.0.0, then inspect the MatRipple event handling. Determine how child elements could suppress the parent ripple without timing-dependent workarounds. Done means clicks on designated child elements do not trigger the container ripple while normal container clicks still do.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.