Skip to content

Commit 81935ad

Browse files
authored
refactor(material/tooltip): use overlay outside click tracking (#23123)
Switches the tooltip to the outside click tracking from the `OverlayRef`, rather than having to maintain its own. This also results in fewer listeners on the `body`.
1 parent de22048 commit 81935ad

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/material-experimental/mdc-tooltip/tooltip.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ export class MatTooltip extends _MatTooltipBase<TooltipComponent> {
109109
// Forces the element to have a layout in IE and Edge. This fixes issues where the element
110110
// won't be rendered if the animations are disabled or there is no web animations polyfill.
111111
'[style.zoom]': '_visibility === "visible" ? 1 : null',
112-
'(body:click)': 'this._handleBodyInteraction()',
113-
'(body:auxclick)': 'this._handleBodyInteraction()',
114112
'aria-hidden': 'true',
115113
}
116114
})

src/material/tooltip/tooltip.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@ export abstract class _MatTooltipBase<T extends _TooltipComponentBase> implement
426426
.pipe(takeUntil(this._destroyed))
427427
.subscribe(() => this._detach());
428428

429+
this._overlayRef.outsidePointerEvents()
430+
.pipe(takeUntil(this._destroyed))
431+
.subscribe(() => this._tooltipInstance?._handleBodyInteraction());
432+
429433
return this._overlayRef;
430434
}
431435

@@ -892,8 +896,6 @@ export abstract class _TooltipComponentBase implements OnDestroy {
892896
// Forces the element to have a layout in IE and Edge. This fixes issues where the element
893897
// won't be rendered if the animations are disabled or there is no web animations polyfill.
894898
'[style.zoom]': '_visibility === "visible" ? 1 : null',
895-
'(body:click)': 'this._handleBodyInteraction()',
896-
'(body:auxclick)': 'this._handleBodyInteraction()',
897899
'aria-hidden': 'true',
898900
}
899901
})

0 commit comments

Comments
 (0)