Skip to content

Commit 32c25ae

Browse files
authored
refactor(multiple): expose private APIs for internal migration (#30947)
Exposes some private APIs in a few components to help with an internal migration.
1 parent 6bdea0b commit 32c25ae

File tree

6 files changed

+14
-3
lines changed

6 files changed

+14
-3
lines changed

goldens/material/autocomplete/index.api.md

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn
197197
_onTouched: () => void;
198198
openPanel(): void;
199199
readonly optionSelections: Observable<MatOptionSelectionChange>;
200+
readonly _overlayPanelClass: string[];
200201
get panelClosingActions(): Observable<MatOptionSelectionChange | null>;
201202
get panelOpen(): boolean;
202203
position: 'auto' | 'above' | 'below';

goldens/material/snack-bar/index.api.md

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy
104104
// @deprecated
105105
attachDomPortal: (portal: DomPortal) => void;
106106
attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>;
107+
// (undocumented)
108+
readonly _elementRef: ElementRef<HTMLElement>;
107109
enter(): void;
108110
exit(): Observable<void>;
109111
_label: ElementRef;

goldens/material/tooltip/index.api.md

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
7272
ngAfterViewInit(): void;
7373
ngOnDestroy(): void;
7474
// (undocumented)
75+
_overlayPanelClass: string[] | undefined;
76+
// (undocumented)
7577
_overlayRef: OverlayRef | null;
7678
get position(): TooltipPosition;
7779
set position(value: TooltipPosition);

src/material/autocomplete/autocomplete-trigger.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
forwardRef,
4242
inject,
4343
} from '@angular/core';
44+
import {coerceArray} from '@angular/cdk/coercion';
4445
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
4546
import {
4647
MatOption,
@@ -208,6 +209,9 @@ export class MatAutocompleteTrigger
208209
/** Stream of keyboard events that can close the panel. */
209210
private readonly _closeKeyEventStream = new Subject<void>();
210211

212+
/** Classes to apply to the panel. Exposed as a public property for internal usage. */
213+
readonly _overlayPanelClass = coerceArray(this._defaults?.overlayPanelClass || []);
214+
211215
/**
212216
* Event handler for when the window is blurred. Needs to be an
213217
* arrow function in order to preserve the context.
@@ -905,7 +909,7 @@ export class MatAutocompleteTrigger
905909
direction: this._dir ?? undefined,
906910
hasBackdrop: this._defaults?.hasBackdrop,
907911
backdropClass: this._defaults?.backdropClass,
908-
panelClass: this._defaults?.overlayPanelClass,
912+
panelClass: this._overlayPanelClass,
909913
disableAnimations: this._animationsDisabled,
910914
});
911915
}

src/material/snack-bar/snack-bar-container.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const EXIT_ANIMATION = '_mat-snack-bar-exit';
6565
})
6666
export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy {
6767
private _ngZone = inject(NgZone);
68-
private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
68+
readonly _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
6969
private _changeDetectorRef = inject(ChangeDetectorRef);
7070
private _platform = inject(Platform);
7171
protected _animationsDisabled = _animationsDisabled();

src/material/tooltip/tooltip.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
215215

216216
_overlayRef: OverlayRef | null;
217217
_tooltipInstance: TooltipComponent | null;
218+
_overlayPanelClass: string[] | undefined; // Used for styling internally.
218219

219220
private _portal: ComponentPortal<TooltipComponent>;
220221
private _position: TooltipPosition = 'below';
@@ -525,6 +526,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
525526
.getAncestorScrollContainers(this._elementRef);
526527

527528
const overlay = this._injector.get(Overlay);
529+
const panelClass = `${this._cssClassPrefix}-${PANEL_CLASS}`;
528530

529531
// Create connected position strategy that listens for scroll events to reposition.
530532
const strategy = overlay
@@ -550,7 +552,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
550552
this._overlayRef = overlay.create({
551553
direction: this._dir,
552554
positionStrategy: strategy,
553-
panelClass: `${this._cssClassPrefix}-${PANEL_CLASS}`,
555+
panelClass: this._overlayPanelClass ? [...this._overlayPanelClass, panelClass] : panelClass,
554556
scrollStrategy: this._injector.get(MAT_TOOLTIP_SCROLL_STRATEGY)(),
555557
disableAnimations: this._animationsDisabled,
556558
});

0 commit comments

Comments
 (0)