Skip to content

refactor(multiple): expose private APIs for internal migration #30947

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

Merged
merged 1 commit into from
Apr 24, 2025
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
1 change: 1 addition & 0 deletions goldens/material/autocomplete/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn
_onTouched: () => void;
openPanel(): void;
readonly optionSelections: Observable<MatOptionSelectionChange>;
readonly _overlayPanelClass: string[];
get panelClosingActions(): Observable<MatOptionSelectionChange | null>;
get panelOpen(): boolean;
position: 'auto' | 'above' | 'below';
Expand Down
2 changes: 2 additions & 0 deletions goldens/material/snack-bar/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy
// @deprecated
attachDomPortal: (portal: DomPortal) => void;
attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C>;
// (undocumented)
readonly _elementRef: ElementRef<HTMLElement>;
enter(): void;
exit(): Observable<void>;
_label: ElementRef;
Expand Down
2 changes: 2 additions & 0 deletions goldens/material/tooltip/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
ngAfterViewInit(): void;
ngOnDestroy(): void;
// (undocumented)
_overlayPanelClass: string[] | undefined;
// (undocumented)
_overlayRef: OverlayRef | null;
get position(): TooltipPosition;
set position(value: TooltipPosition);
Expand Down
6 changes: 5 additions & 1 deletion src/material/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
forwardRef,
inject,
} from '@angular/core';
import {coerceArray} from '@angular/cdk/coercion';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {
MatOption,
Expand Down Expand Up @@ -208,6 +209,9 @@ export class MatAutocompleteTrigger
/** Stream of keyboard events that can close the panel. */
private readonly _closeKeyEventStream = new Subject<void>();

/** Classes to apply to the panel. Exposed as a public property for internal usage. */
readonly _overlayPanelClass = coerceArray(this._defaults?.overlayPanelClass || []);

/**
* Event handler for when the window is blurred. Needs to be an
* arrow function in order to preserve the context.
Expand Down Expand Up @@ -905,7 +909,7 @@ export class MatAutocompleteTrigger
direction: this._dir ?? undefined,
hasBackdrop: this._defaults?.hasBackdrop,
backdropClass: this._defaults?.backdropClass,
panelClass: this._defaults?.overlayPanelClass,
panelClass: this._overlayPanelClass,
disableAnimations: this._animationsDisabled,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/snack-bar/snack-bar-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const EXIT_ANIMATION = '_mat-snack-bar-exit';
})
export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy {
private _ngZone = inject(NgZone);
private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
readonly _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
private _changeDetectorRef = inject(ChangeDetectorRef);
private _platform = inject(Platform);
protected _animationsDisabled = _animationsDisabled();
Expand Down
4 changes: 3 additions & 1 deletion src/material/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {

_overlayRef: OverlayRef | null;
_tooltipInstance: TooltipComponent | null;
_overlayPanelClass: string[] | undefined; // Used for styling internally.

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

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

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