question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: ion-label not floating inside ion-item with select input on ion-modal dialog

See original GitHub issue

Prequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

ion-label not floating inside ion-item with select input on ion-modal dialog, label overlay the select field value. Selecting a new value fix the overlay bug, however, it comes back reopening the dialog. The bug not exists on modeless views.

2021-08-24_16-22-33

Expected Behavior

Floating ion-label not overlay on select fields in both normal and ion.modal view.

Steps to Reproduce

Create a modal and open a modal with an ion-label with floating prop with an ion-select.

<ion-item> <ion-label color="primary" position="floating">Posizione </ion-label> <ion-select multiple="false" formControlName="nascSesso" [(ngModel)]="this.entita.Collaboratore.Anagrafica.NascSesso" [cancelText]="this.translateService.instant('component.select.cancelText')" ok-text="Ok"> <ion-select-option *ngFor="let item of this.tipoSesso | keys" [value]="item.key"> {{ 'Youpass.model.anagrafica.EnumSesso.' + item.value | translate }}</ion-select-option> </ion-select> </ion-item>

Code Reproduction URL

https://github.com/olaisen81/ion-label-issue

Ionic Info

2021-08-24_16-24-22

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
liamdebeasicommented, Sep 30, 2021

After some discussion with the Angular team, this looks like something we need to address inside of Ionic: https://github.com/angular/angular-cli/issues/21682

Ionic was leveraging a defect in zone.js which caused async operations to not be intercepted, resulting in this issue. It was technically an issue before this thread was opened, but we never noticed it until now because native async/await was not previously downlevelled.

I will look into a fix soon.

3reactions
a2kancommented, Dec 14, 2021

I applied a workaround to this problem for now, After setting the value of the select if you add “item-has-value” class to parent item element of the select in a setTimeout function, the things works somehow as expected.

@ViewChild(‘item’, { static: false }) item: any; … setTimeout(() => { this.item.el.classList.add(‘item-has-value’);
}, 100);

 <ion-item #item>
  <ion-label position="floating">
              label
            </ion-label>
            <ion-select></ion-select>
</ion-item>
Read more comments on GitHub >

github_iconTop Results From Across the Web

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-modal: Ionic Mobile App Custom Modal ... - Ionic Framework
ion-modal is a dialog that appears on top of mobile app content, and must be dismissed before interaction resumes. Learn more about custom...
Read more >
5 Examples of the new Ionic 6 Bottom Sheet Modal
Get the details on how to use the brand new Ionic Bottom Sheet component in this guest blog post from Simon Grimm.
Read more >
Wrong Focus With Ionic 3 Ion-Input - ADocLib
You can do it <ionitem> <ionlabel stacked>Username</ionlabel> <ioninput Learn more ... The Content scrolling on input focus does not work in this case....
Read more >
@ionic/core | Yarn - Package Manager
Bug Fixes. datetime: add flipRTL to monthAndYear dropdown icon (#26378 (13fe669); datetime: md highlight does not clip at start or end of month...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found