Skip to content

Commit 5653865

Browse files
committed
fix(material/select): use flexible overlay dimensions
1 parent 765f54d commit 5653865

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/material/select/select.html

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
[cdkConnectedOverlayOrigin]="_preferredOverlayOrigin || fallbackOverlayOrigin"
4040
[cdkConnectedOverlayPositions]="_positions"
4141
[cdkConnectedOverlayWidth]="_overlayWidth"
42+
[cdkConnectedOverlayFlexibleDimensions]="true"
4243
(backdropClick)="close()"
4344
(overlayKeydown)="_handleOverlayKeydown($event)">
4445
<div

src/material/select/select.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import {
8282
MatOptionSelectionChange,
8383
} from '../core';
8484
import {MAT_FORM_FIELD, MatFormField, MatFormFieldControl} from '../form-field';
85-
import {defer, merge, Observable, Subject} from 'rxjs';
85+
import {defer, merge, Observable, Subject, Subscription} from 'rxjs';
8686
import {filter, map, startWith, switchMap, take, takeUntil} from 'rxjs/operators';
8787
import {
8888
getMatSelectDynamicMultipleError,
@@ -734,6 +734,8 @@ export class MatSelect
734734
this.panelOpen ? this.close() : this.open();
735735
}
736736

737+
_positionChangeSubscription: Subscription;
738+
737739
/** Opens the overlay panel. */
738740
open(): void {
739741
if (!this._canOpen()) {
@@ -751,10 +753,17 @@ export class MatSelect
751753
this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
752754
this._applyModalPanelOwnership();
753755
this._panelOpen = true;
754-
this._overlayDir.positionChange.pipe(take(1)).subscribe(() => {
756+
this._overlayDir.positionChange.pipe(take(1)).subscribe(arg => {
755757
this._changeDetectorRef.detectChanges();
756758
this._positioningSettled();
757759
});
760+
if (this._positionChangeSubscription) {
761+
this._positionChangeSubscription.unsubscribe();
762+
}
763+
this._positionChangeSubscription = this._overlayDir.positionChange.subscribe(change => {
764+
// debugger;
765+
console.log(this._overlayDir);
766+
});
758767
this._overlayDir.attachOverlay();
759768
this._keyManager.withHorizontalOrientation(null);
760769
this._highlightCorrectOption();

0 commit comments

Comments
 (0)