bug: ion-select / ion-label not displayed properly with attribute floating
See original GitHub issue#19712 Bug Report
Ionic version: [x] **4.11.3
Current behavior: When using ion-select inside and ion-item, the ion-label (with floating attribute) is displayed on top of the selected value of the ion-select
Expected behavior: The label shall be displayed with small font upper
Related code:
<ion-item>
<ion-label position="floating">Event Game</ion-label>
<ion-select [(ngModel)]="selectedGame.key" (ionChange)="onChangeGame()">
<ion-select-option *ngFor="let game of gameLst" [value]="game.key">{{game.value}}</ion-select-option>
</ion-select>
</ion-item>
Here is a project showing the issue: https://github.com/eltoky/tstSelect
Ionic info:
Ionic:
Ionic CLI : 5.4.6 (/Users/x/.nvm/versions/node/v10.16.0/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.11.3
@angular-devkit/build-angular : 0.802.2
@angular-devkit/schematics : 8.3.17
@angular/cli : 8.3.17
@ionic/angular-toolkit : 2.1.1
Capacitor:
Capacitor CLI : 1.3.0
@capacitor/core : 1.3.0
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (0 plugins total)
Utility:
cordova-res : not installed
native-run : 0.2.7 (update available: 0.2.9)
System:
NodeJS : v10.16.0 (/Users/x/.nvm/versions/node/v10.16.0/bin/node)
npm : 6.13.0
OS : macOS Mojave
Xcode : Xcode 11.2.1 Build version 11B500
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
bug: ion-select / ion-label not displayed properly with attribute ...
It seems to be a problem (yet, in Ionic 6.0.2) when the scenario is: use of dynamic items (using ngFor, for instance to...
Read more >ion-select / ion-label not displayed properly with attribute ...
That way the pre-selected value shows and the label is floated like expected. So, try: <ion-select [(ngModel)]="tstObj.key" (ionChange)= ...
Read more >ion-select / ion-label not displayed properly with attribute ...
Best coding solution for query ion-select / ion-label not displayed properly with attribute floating in Ionic 4.
Read more >ion-datetime - Ionic Framework
Datetimes present a picker interface to select dates and times. Ionic's API Datetime input component easily displays a preferred format, and manages values....
Read more >Advanced Forms & Validation in Ionic & Angular | Josh Morony
We must also set the formGroup property on the parent <form> to have the ... <ion-label position="floating">Privacy</ion-label> <ion-select ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, i’ve got the same issue with latest angular (12.2.2) and ionic (5.6.14) version, any update or fix? For now i resolved applying item-has-value class to item parent element, but it’s a temporary workaround:
ngAfterViewInit(): void { this.ionSelectPosizione.el.parentElement.classList.add("item-has-value"); }
@brandyscarney
Here’s a simple 20 line reproduction on the latest version 5.6.4, vanilla Javascript, no Angular involved here.
https://jsfiddle.net/e2t31qaw/
The order of events matters. What seems to cause this bug specifically is:
select.innerHTML = '';
select.setAttribute('value', 'option1');
ion-select-option
elements and appending them to theion-select
afterwards.The jsfiddle link above shows this: