Skip to content

bug: using switch/ngIf causes label to flicker #22541

Closed

Description

@DavidStrausz

Bug Report

Ionic version:

[ ] 4.x
[x] 5.x

Current behavior:
When switching between multiple ion-item components with a stacked label they cause an ugly flicker. It seems like the label is first rendered in the default position and then it switches to the stacked position.
This was the way I noticed the bug - it probably also happens in a lot of other situations where an ion-item with a stacked label is rendered.

Example gif:

Expected behavior:
No flicker :)

Steps to reproduce:

  • Clone example repo
  • npm i
  • ionic s
  • On Tab 1 use the segments to switch between the ion-items with stacked labels

Related code:
Github app: stacked-label-flicker

Other information:

  • Happens in md and ios mode
  • Happens with Angular 10 and 11
  • Happens when running on a device and also when running the browser
  • Happens with @ionic/angular 5.0.0 and also 5.5.0

Ionic info:

Ionic:

   Ionic CLI                     : 5.2.4 (C:\Users\dstrauss.VENTO\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 5.5.0
   @angular-devkit/build-angular : 0.1100.2                                                      |   
   @angular-devkit/schematics    : 10.0.8
   @angular/cli                  : 11.0.2                                                        | 36
   @ionic/angular-toolkit        : 2.3.3
                                                                                                 |   
Utility:
                                                                                         -module | 12
   cordova-res : 0.15.1
   native-run  : 0.2.8

System:

   NodeJS : v14.3.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.14.5
   OS     : Windows 10

Activity

  1. changed the title [-]bug: stacked labes flicker during rendering[/-] [+]bug: stacked labels flicker during rendering[/+] on Nov 20, 2020
  2. changed the title [-]bug: stacked labels flicker during rendering[/-] [+]bug: using switch/ngIf causes label to flicker[/+] on Nov 20, 2020
  3. DavidStrausz commented on Jan 25, 2021

    @DavidStrausz
    ContributorAuthor

    FYI: The behaviour is still observable with ionic 5.5.2 and angular 11.1.0.

  4. Chreggii commented on Apr 8, 2021

    @Chreggii

    Any updates regarding this issue?

  5. sean-perkins commented on Dec 1, 2021

    @sean-perkins
    Contributor

    Follow-up on this issue.

    The problem is that ion-item does not know to apply the .item-label-stacked class until after ion-label renders and emits ionStyle. This causes a render cycle to complete with the incorrect styles, before applying the correct class.

    In the interim, you can help ion-item render correctly by directly applying the class to the element when you know its contents contains a stacked label.

    <ion-item class="item-label-stacked">
      <ion-label position="stacked">Test</ion-label>
      <ion-input value="123"></ion-input>
    </ion-item>
  6. DavidStrausz commented on Dec 2, 2021

    @DavidStrausz
    ContributorAuthor

    Thank you @sean-perkins! The suggested workaround works perfectly for now!

  7. liamdebeasi commented on Feb 3, 2023

    @liamdebeasi
    Contributor

    Thanks for the report. In Ionic 7 we are introducing a new syntax for working with ion-input. Additionally, Ionic 7 has a performance improvement for Ionic Angular that should reduce the initialization time for Ionic components. This issue is fixed when using the improvements in Ionic 7. Please see https://ionic.io/blog/announcing-the-ionic-7-beta for more on Ionic 7 as well as how to get started with the Ionic 7 beta.

    The work required to resolve this has been completed, so I am going to close this thread. Let me know if there are any questions.

  8. ionitron-bot commented on Mar 5, 2023

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  9. locked and limited conversation to collaborators on Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions