Skip to content

[MatRipple] Hover/Touch Event listeners are still added when ripples are disabled via a MAT_RIPPLE_GLOBAL_OPTIONS Provider #16100

Closed
@justinappler

Description

@justinappler

Reproduction

https://stackblitz.com/edit/components-issue-asjy3a

Steps to reproduce:

  1. Add a provider for MAT_RIPPLE_GLOBAL_OPTIONS that disabled ripples, e.g.
@Injectable({providedIn: 'root'})
export class AppGlobalRippleOptions implements RippleGlobalOptions {
  disabled: boolean = true;
}
  1. Include a Material Component that uses MatRipple, but doesn't disable them via the component input (e.g. MatButton).

Expected Behavior

When Ripples are globally disabled, elements containing a MatRipple should not have event listeners attached to the target elements.

Actual Behavior

Even when Ripples are globally disabled via a MAT_RIPPLE_GLOBAL_OPTIONS Provider, elements with MatRipples will have six click/touch listeners attached. These listeners are not themselves problematic, but when many components are present on the page represent a significant performance hit.

It looks like the last work done on this was in #11865. I discovered this issue when trying to enable and disable ripples at runtime as described in the documentation (as a means to further improve initial page load performance (a surprising amount of time is consumed setting up these 6 event listeners per element).

Environment

  • Angular: 7.2.3
  • CDK/Material: 7.3.0
  • Browser(s): n/a (All)
  • Operating System (e.g. Windows, macOS, Ubuntu): n/a (All)

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functionsarea: material/coreperfThis issue is related to performance

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions