Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Focus flashes on input field when opening a modal from a popover #24820

Closed
4 of 6 tasks
raymer opened this issue Feb 20, 2022 · 6 comments · Fixed by #25481
Closed
4 of 6 tasks

bug: Focus flashes on input field when opening a modal from a popover #24820

raymer opened this issue Feb 20, 2022 · 6 comments · Fixed by #25481
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@raymer
Copy link

raymer commented Feb 20, 2022

Prerequisites

Ionic Framework Version

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

Current Behavior

When opening a modal from a popover click event, if that modal has form fields, the first one is given immediate focus, then immediately blurred, causing a flashing effect.

Expected Behavior

The input field in a modal opened by a popover does not receive focus then immediately blur.

Steps to Reproduce

Create an inline popover that has a child with a click event that opens a modal that contains an input field.

Page with popover

<template>
  <ion-page>
    <ion-content :fullscreen="true" color="light">
      <ion-button @click="setOpen(true, $event)" shape="round" fill="clear" color="dark" size="small">
        <ion-icon :icon="ellipsisVertical"></ion-icon>
      </ion-button>
      <ion-popover :is-open="isOpen" :event="locationEvent" :dismissOnSelect="true" @didDismiss="setOpen(false)">
        <ion-item class="context-item" lines="full" @click="openModal">Test</ion-item>
      </ion-popover>
    </ion-content>
  </ion-page>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { IonButton, IonPopover, IonIcon, IonPage, IonContent, modalController, IonItem } from '@ionic/vue';
import { ellipsisVertical } from 'ionicons/icons';
import ModalVue from './Modal.vue';

const isOpen = ref(false);
const locationEvent = ref<Event>();

function setOpen(state: boolean, event?: Event) {
  locationEvent.value = event;
  isOpen.value = state;
}

const openModal = async () => {
  const modal = await modalController
    .create({
      component: ModalVue
    })
  modal.present();
  await modal.onDidDismiss();
}
</script>

Modal.vue

<template>
  <ion-item>
    <ion-label position="floating">Label</ion-label>
    <ion-input></ion-input>
  </ion-item>
</template>

<script lang="ts" setup>
import { IonItem, IonLabel, IonInput } from '@ionic/vue';
</script>

Code Reproduction URL

https://github.com/raymer/ionic-bug

Ionic Info

Ionic:

Ionic CLI : 5.4.16 (C:\Users\rayme\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/vue 6.0.1

Capacitor:

Capacitor CLI : 3.2.4
@capacitor/core : 3.4.1

Utility:

cordova-res : not installed
native-run : 1.5.0

System:

NodeJS : v16.13.1 (C:\Program Files\nodejs\node.exe)
npm : 8.3.0
OS : Windows 10

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Feb 20, 2022
@sean-perkins
Copy link
Contributor

@raymer thanks for reporting this issue. I'm able to replicate against your reproduction.

It does look like our focus trapping behavior is setting focus on the first form control and then immediately changing focus to the root ion-modal node, which causes a visual defect.

We will track this as a bug and prioritize.

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Jun 15, 2022

Thanks for the issue. Can you try the following dev build and let me know if it resolves the issue?

npm install @ionic/[email protected] @ionic/[email protected]

@raymer
Copy link
Author

raymer commented Jun 15, 2022

@liamdebeasi I will try as soon as possible and report back. Thanks!

@raymer
Copy link
Author

raymer commented Jun 15, 2022

@liamdebeasi tested and verified it resolves the issue. Thanks again!

liamdebeasi added a commit that referenced this issue Jun 16, 2022
@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #25481, and a fix will be available in an upcoming release of Ionic Framework.

@ionitron-bot
Copy link

ionitron-bot bot commented Jul 16, 2022

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jul 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants