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

bug(material/core): ripple element not destroyed after trigger change #29010

Closed
1 task
enten opened this issue May 7, 2024 · 1 comment · Fixed by #29012
Closed
1 task

bug(material/core): ripple element not destroyed after trigger change #29010

enten opened this issue May 7, 2024 · 1 comment · Fixed by #29012
Labels
area: material/core P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@enten
Copy link
Contributor

enten commented May 7, 2024

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

9.2.0

Description

The RippleRenderer register pointer up events only once: that "breaks" matRippleTrigger input from MatRipple directive and prevents destruction of new ripple elements after trigger element change.

This issue was introduced since @angular/material v9.2.1 (commit 9a16e60 in GH-18633 ).

How to fix: mark pointer up events as not registered in RippleRenderer::_removeTriggerEvents.

diff --git a/src/material/core/ripple/ripple-renderer.ts b/src/material/core/ripple/ripple-renderer.ts
index 87c1520c2..dc0296ce1 100644
--- a/src/material/core/ripple/ripple-renderer.ts
+++ b/src/material/core/ripple/ripple-renderer.ts
@@ -433,6 +433,8 @@ export class RippleRenderer implements EventListenerObject {
         pointerUpEvents.forEach(type =>
           trigger.removeEventListener(type, this, passiveCapturingEventOptions),
         );
+
+        this._pointerUpEventsRegistered = false;
       }
     }
   }

Reproduction

StackBlitz link: https://stackblitz.com/edit/components-issue-z9j3qe
Steps to reproduce:

  1. Click on "Trigger A" button
  2. Click on "Change Trigger Button" button
  3. Click on "Trigger B" button

Result:
image

Expected Behavior

The RippleRenderer must register pointer up events each time a trigger is setup.

Actual Behavior

The RippleRenderer currently register pointer up events only once.

Environment

  • Angular:
  • CDK/Material: Any version since @angular/material v9.2.1
  • Browser(s): Any
  • Operating System (e.g. Windows, macOS, Ubuntu): Any
@enten enten added the needs triage This issue needs to be triaged by the team label May 7, 2024
enten added a commit to enten/components that referenced this issue May 7, 2024
@enten enten changed the title bug(MatRipple): pointer up events are registered once bug(MatRipple): ripple element not destroyed after trigger change May 7, 2024
@enten enten changed the title bug(MatRipple): ripple element not destroyed after trigger change bug(material/core): ripple element not destroyed after trigger change May 8, 2024
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/core and removed needs triage This issue needs to be triaged by the team labels May 8, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/core P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants