* Implemented as part of MatFormFieldControl. * @docs-private
()
| 522 | * @docs-private |
| 523 | */ |
| 524 | get shouldLabelFloat(): boolean { |
| 525 | if (this._isNativeSelect) { |
| 526 | // For a single-selection `<select>`, the label should float when the selected option has |
| 527 | // a non-empty display value. For a `<select multiple>`, the label *always* floats to avoid |
| 528 | // overlapping the label with the options. |
| 529 | const selectElement = this._elementRef.nativeElement as HTMLSelectElement; |
| 530 | const firstOption: HTMLOptionElement | undefined = selectElement.options[0]; |
| 531 | |
| 532 | // On most browsers the `selectedIndex` will always be 0, however on IE and Edge it'll be |
| 533 | // -1 if the `value` is set to something, that isn't in the list of options, at a later point. |
| 534 | return ( |
| 535 | this.focused || |
| 536 | selectElement.multiple || |
| 537 | !this.empty || |
| 538 | !!(selectElement.selectedIndex > -1 && firstOption && firstOption.label) |
| 539 | ); |
| 540 | } else { |
| 541 | return (this.focused && !this.disabled) || !this.empty; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * Implemented as part of MatFormFieldControl. |
nothing calls this directly
no outgoing calls
no test coverage detected