Skip to content

bug: ion-loading race condition when toggled via bound prop #22880

@troygilbert

Description

@troygilbert

Bug Report

Ionic version:
[ ] 4.x
[x] 5.x

Current behavior:
If you show/hide an <ion-loading> element too quickly you will orphan the DOM element and a new one will be created (the old one will never go away).

Expected behavior:
The component should gracefully handle showing/hiding via a bound prop.

Steps to reproduce:
Use ionic start to create an empty starter project, select Vue, then replace Home.vue with:

<template>
  <ion-page>
    <ion-content>
      <ion-loading :is-open="loadingMessage" :message="loadingMessage"></ion-loading>
      <ion-button @click="startLoading">Start Loading</ion-button>
    </ion-content>
  </ion-page>
</template>

<script lang="ts">
  import { IonContent, IonPage, IonButton, IonLoading } from '@ionic/vue';
  import { defineComponent } from 'vue';

  export default defineComponent({
    name: 'Home',
    components: { IonContent, IonPage, IonButton, IonLoading },
    data() {
      return {
        loadingMessage: '',
      };
    },
    methods: {
      startLoading() {
        this.loadingMessage = 'A really long loading message so you can see it in the background...';
        setTimeout(() => {
          this.loadingMessage = '';
          setTimeout(() => {
            this.loadingMessage = 'Loading again...';
          });
        });
      },
    },
  });
</script>

Ionic info:

Ionic:

   Ionic CLI       : 6.12.3 (/Users/troygilbert/.nvm/versions/node/v14.15.2/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 5.5.4

Capacitor:

   Capacitor CLI   : 2.4.6
   @capacitor/core : 2.4.6

Utility:

   cordova-res (update available: 0.15.3) : 0.15.2
   native-run                             : 1.3.0

System:

   NodeJS : v14.15.2 (/Users/troygilbert/.nvm/versions/node/v14.15.2/bin/node)
   npm    : 6.14.10
   OS     : macOS Big Sur

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions