Skip to content

Commit 28d12e4

Browse files
mmalerbaandrewseguin
authored andcommitted
fix(material-experimental/mdc-select): fix floating label behavior (#22134)
(cherry picked from commit 16b7adb)
1 parent f950c03 commit 28d12e4

File tree

1 file changed

+3
-2
lines changed
  • src/material-experimental/mdc-select

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
116116
get shouldLabelFloat(): boolean {
117117
// Since the panel doesn't overlap the trigger, we
118118
// want the label to only float when there's a value.
119-
return !this.empty;
119+
return this.panelOpen || !this.empty;
120120
}
121121

122122
ngOnInit() {
@@ -147,11 +147,12 @@ export class MatSelect extends _MatSelectBase<MatSelectChange> implements OnInit
147147
open() {
148148
this._overlayWidth = this._getOverlayWidth();
149149
super.open();
150+
// Required for the MDC form field to pick up when the overlay has been opened.
151+
this.stateChanges.next();
150152
}
151153

152154
close() {
153155
super.close();
154-
155156
// Required for the MDC form field to pick up when the overlay has been closed.
156157
this.stateChanges.next();
157158
}

0 commit comments

Comments
 (0)