Skip to content

Commit 96e01d1

Browse files
committed
fix(material/select): global option not disabling popover
Fixes that disabling popovers globally wasn't doing so for `mat-select`. Relates to #32592 (comment).
1 parent 869d4f8 commit 96e01d1

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

goldens/material/paginator/index.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { Directionality } from '@angular/cdk/bidi';
2121
import { DoCheck } from '@angular/core';
2222
import { ElementRef } from '@angular/core';
2323
import { EventEmitter } from '@angular/core';
24+
import { FlexibleOverlayPopoverLocation } from '@angular/cdk/overlay';
2425
import { FocusableOption } from '@angular/cdk/a11y';
2526
import { FocusOrigin } from '@angular/cdk/a11y';
2627
import { FormGroupDirective } from '@angular/forms';

goldens/material/select/index.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ControlValueAccessor } from '@angular/forms';
2020
import { DoCheck } from '@angular/core';
2121
import { ElementRef } from '@angular/core';
2222
import { EventEmitter } from '@angular/core';
23+
import { FlexibleOverlayPopoverLocation } from '@angular/cdk/overlay';
2324
import { FocusableOption } from '@angular/cdk/a11y';
2425
import { FocusOrigin } from '@angular/cdk/a11y';
2526
import { FormGroupDirective } from '@angular/forms';
@@ -340,6 +341,8 @@ export class MatSelect implements AfterContentInit, OnChanges, OnDestroy, OnInit
340341
protected _parentFormField: MatFormField | null;
341342
get placeholder(): string;
342343
set placeholder(value: string);
344+
// (undocumented)
345+
protected _popoverLocation: FlexibleOverlayPopoverLocation | null;
343346
_positions: ConnectedPosition[];
344347
_preferredOverlayOrigin: CdkOverlayOrigin | ElementRef | undefined;
345348
registerOnChange(fn: (value: any) => void): void;

src/material/select/select.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
[cdkConnectedOverlayPositions]="_positions"
4141
[cdkConnectedOverlayWidth]="_overlayWidth"
4242
[cdkConnectedOverlayFlexibleDimensions]="true"
43-
cdkConnectedOverlayUsePopover="inline"
43+
[cdkConnectedOverlayUsePopover]="_popoverLocation"
4444
(detach)="close()"
4545
(backdropClick)="close()"
4646
(overlayKeydown)="_handleOverlayKeydown($event)">

src/material/select/select.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import {
3131
CdkOverlayOrigin,
3232
ConnectedPosition,
3333
createRepositionScrollStrategy,
34+
FlexibleOverlayPopoverLocation,
35+
OVERLAY_DEFAULT_CONFIG,
3436
ScrollStrategy,
3537
} from '@angular/cdk/overlay';
3638
import {ViewportRuler} from '@angular/cdk/scrolling';
@@ -210,6 +212,7 @@ export class MatSelect
210212
private _liveAnnouncer = inject(LiveAnnouncer);
211213
protected _defaultOptions = inject(MAT_SELECT_CONFIG, {optional: true});
212214
protected _animationsDisabled = _animationsDisabled();
215+
protected _popoverLocation: FlexibleOverlayPopoverLocation | null;
213216
private _initialized = new Subject();
214217
private _cleanupDetach: (() => void) | undefined;
215218

@@ -602,6 +605,7 @@ export class MatSelect
602605
const parentForm = inject(NgForm, {optional: true});
603606
const parentFormGroup = inject(FormGroupDirective, {optional: true});
604607
const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true});
608+
const defaultPopoverConfig = inject(OVERLAY_DEFAULT_CONFIG, {optional: true});
605609

606610
if (this.ngControl) {
607611
// Note: we provide the value accessor through here, instead of
@@ -622,8 +626,10 @@ export class MatSelect
622626
parentForm,
623627
this.stateChanges,
624628
);
629+
625630
this._scrollStrategy = this._scrollStrategyFactory();
626631
this.tabIndex = tabIndex == null ? 0 : parseInt(tabIndex) || 0;
632+
this._popoverLocation = defaultPopoverConfig?.usePopover === false ? null : 'inline';
627633

628634
// Force setter to be called in case id was not specified.
629635
this.id = this.id;

0 commit comments

Comments
 (0)