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

feat(material/core): Allow namespacing ripple-loader event handler #28699

Merged
merged 1 commit into from
Mar 13, 2024
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
6 changes: 4 additions & 2 deletions src/material/core/private/ripple-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class MatRippleLoader implements OnDestroy {
},
): void {
// Indicates that the ripple has not yet been rendered for this component.
host.setAttribute(matRippleUninitialized, '');
host.setAttribute(matRippleUninitialized, this._globalRippleOptions?.namespace ?? '');

// Store the additional class name(s) that should be added to the ripple element.
if (config.className || !host.hasAttribute(matRippleClassName)) {
Expand Down Expand Up @@ -139,7 +139,9 @@ export class MatRippleLoader implements OnDestroy {

// TODO(wagnermaciel): Consider batching these events to improve runtime performance.

const element = eventTarget.closest(`[${matRippleUninitialized}]`);
const element = eventTarget.closest(
`[${matRippleUninitialized}="${this._globalRippleOptions?.namespace ?? ''}"]`,
);
if (element) {
this._createRipple(element as HTMLElement);
}
Expand Down
5 changes: 5 additions & 0 deletions src/material/core/ripple/ripple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export interface RippleGlobalOptions {
* default, ripples will wait for the enter animation to complete and for mouse or touch release.
*/
terminateOnPointerUp?: boolean;

/**
* A namespace to use for ripple loader to allow multiple instances to exist on the same page.
*/
namespace?: string;
}

/** Injection token that can be used to specify the global ripple options. */
Expand Down
Loading