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: ion-input & setFocus() is not working in iOS 13.1.3 #19699

Closed
Livijn opened this issue Oct 19, 2019 · 4 comments
Closed

bug: ion-input & setFocus() is not working in iOS 13.1.3 #19699

Livijn opened this issue Oct 19, 2019 · 4 comments
Labels

Comments

@Livijn
Copy link

Livijn commented Oct 19, 2019

Bug Report

Ionic version:
[@ionic/core] 4.11.1
[@ionic/vue] 0.0.9

Current behavior:
Using setFocus() is not setting focus on the input on my USB connected device in iOS 13.1.3. However it does work in the iPhone Simulator. Both in the native Safari browser and in my app. The Simulator is using 13.1 not 13.1.3.

Expected behavior:
Using setFocus() should set focus on the input in iOS 13.1.3.

Related code:
This code is fired when clicking a button. The console logs the correct <ion-input> but the focus isn't getting set.

          setTimeout(() => {
            console.log(this.$refs.input);
            this.$refs.input.setFocus();
          }, 200);

I've also tried using this.$refs.input.querySelector('input').focus() and that doesn't work as well. I'm not sure if this is only related to ionic, but I can't seem to find any solution.

@ionitron-bot ionitron-bot bot added the triage label Oct 19, 2019
@sean118
Copy link

sean118 commented Oct 20, 2019

In case you didn’t figure it out yet: You can just remove the setTimeout and just fire this.$refs.input.setFocus() directly on click, which should work fine.

The actual underlying issue is somewhere in the webview implementation, that doesn’t allow pulling up the keyboard without direct user interaction - so its really an issue related to Capacitor/Cordova/WKWebView.

For Capacitor the issue is probably right here, hidden in the setKeyboardRequiresUserInteraction function, but I also couldn't get it to work:
https://github.com/ionic-team/capacitor/blob/ab1ffd576d541c2423adf422b54d0b1b0483d00e/ios/Capacitor/Capacitor/CAPBridgeViewController.swift

@Livijn
Copy link
Author

Livijn commented Oct 21, 2019

This was a bug in Capacitor not Ionic. Also, @sean118, the bug is fixed in this commit: ionic-team/capacitor#1995

@Livijn Livijn closed this as completed Oct 21, 2019
@sean118
Copy link

sean118 commented Oct 21, 2019

Ah right, thanks, works perfectly 👍

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 20, 2019

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 Nov 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants