Skip to content

bug: autofocus input causes modal animation be incorrect on ios #18257

Open

Description

@msigwart

Bug Report

Ionic version:

[x] 4.x

Current behavior:

The same issue as reported in #16136:
When setting autofocus on an ion-input element in a modal in ios, the modal content disappears.

Expected behavior:

The modal content does not disappear.

Steps to reproduce:

  1. Create an Ionic App
  2. Create a Modal with const modal = await this.modalController.create({...
  3. Set autofocus on an ion-input element in the modal component

Related code:

modal.component.html:

<ion-header>
  <ion-toolbar>
    <ion-title>Some Modal Component</ion-title>
  </ion-toolbar>
</ion-header>
<ion-content padding>
  <ion-item>
    <ion-label position="floating">Some Input</ion-label>
    <ion-input type="text" autofocus></ion-input>
  </ion-item>
</ion-content>

Other information:

Related issue: #16136

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0
   Ionic Framework               : @ionic/angular 4.4.0
   @angular-devkit/build-angular : 0.13.8
   @angular-devkit/schematics    : 7.3.8
   @angular/cli                  : 7.3.8
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 ([email protected])
   Cordova Platforms     : android 7.1.4, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 4 other plugins)

System:

   Android SDK Tools : 26.1.1
   NodeJS            : v11.9.0
   npm               : 6.9.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001

Activity

  1. added
    package: core
    package: angular
    and removed on Jun 3, 2019
  2. calendee commented on Sep 29, 2019

    @calendee

    I am observing the same problem in Ionic React RC2/RC3 on mobile devices only. If the device is rotated to landscape and then back, the "bad" modal displays properly.

    Demo: https://ionic-react-auto-focus-modal-bug.netlify.com

    Reproducible Sample: https://github.com/calendee/ionic-react-auto-focus-modal-bug/tree/master

    Here's a demo of it - watch to the end - sorry it's really slow to demonstrate the whole problem.
    Ionic React Auto Focus Modal Bug 2019-09-29 09_45_47

  3. sagrawal31 commented on Nov 20, 2019

    @sagrawal31

    We are also facing this issue. We are using latest version of @ionic/angular, cordova-plugin-ionic-webview and cordova-plugin-ionic-keyboard

  4. aaadipop commented on Nov 26, 2019

    @aaadipop

    same here

  5. cytrics commented on Sep 15, 2020

    @cytrics

    I still have the problem. is there a solution now?

    System:

    Ionic:

    Ionic CLI : 6.11.1 (/usr/local/lib/node_modules/@ionic/cli)
    Ionic Framework : @ionic/angular 5.2.3
    @angular-devkit/build-angular : 0.901.11
    @angular-devkit/schematics : 9.1.11
    @angular/cli : 9.1.11
    @ionic/angular-toolkit : 2.2.0

    Capacitor:

    Capacitor CLI : 2.2.1
    @capacitor/core : 2.2.1

    Cordova:

    Cordova CLI : 10.0.0
    Cordova Platforms : ios 5.1.1
    Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 7 other plugins)

  6. added
    type: bug
    and removed
    package: angular
    package: core
    on Dec 3, 2020
  7. liamdebeasi commented on Dec 3, 2020

    @liamdebeasi
    Contributor

    Hi everyone,

    This issue appears to be due to a bug in WebKit (the engine that powers Safari) where autofocus causes animations to be run incorrectly. I will look into filing an issue with the WebKit team.

    As of now, I am not aware of a workaround but I will post here if I find one.

  8. flavioribeirojr commented on Jan 11, 2021

    @flavioribeirojr

    Did anyone found a solution or workaround for this?

  9. liamdebeasi commented on Jan 11, 2021

    @liamdebeasi
    Contributor

    No workaround at the moment. I reported this to the WebKit team, and they can reproduce it on their end: https://bugs.webkit.org/show_bug.cgi?id=219506

  10. added
    bug: external
    on Aug 20, 2021
  11. jaminm commented on Sep 16, 2021

    @jaminm

    Same here, caused the modal to jump up past the top of the screen then back down, removed autofocus and it animates correctly. This only happened on iOS phones, Safari and Chrome.

  12. changed the title [-]bug: autofocus input causes modal to disappear on ios[/-] [+]bug: autofocus input causes modal animation be incorrect on ios[/+] on Feb 18, 2022
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

    bug: externaltype: bug

    Type

    Fields

    Stage

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions