Flutter_Pinput icon indicating copy to clipboard operation
Flutter_Pinput copied to clipboard

'autofocus: true' doesn't open keyboard

Open avdhootu27 opened this issue 1 year ago • 3 comments
trafficstars

Describe the bug If I set autofocus=true, the focus goes to pinput but the keyboard doesn't open. I need to tap on the pinput widget to open the keyboard. The keyboard should also open.

To Reproduce Steps to reproduce the behavior:

  1. Set autofocus:true

Screenshots

https://github.com/Tkko/Flutter_Pinput/assets/72180606/ffbb39c9-7878-4695-a237-838568c1500c

Pinput version: 3.0.1

Result of: flutter doctor --verbose

[✓] Flutter (Channel stable, 3.19.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-US) • Flutter version 3.19.0 on channel stable at /Users/avdhoot/Development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision bae5e49bc2 (2 months ago), 2024-02-13 17:46:18 -0800 • Engine revision 04817c99c9 • Dart version 3.3.0 • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/avdhoot/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15E204a • CocoaPods version 1.15.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.88.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available) • iPhone 15 Pro Max (mobile) • E717C647-386F-4E05-82D9-7B956C76D7EC • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.91

[✓] Network resources • All expected network resources are available.

• No issues found!

Smartphone (please complete the following information):

  • Device: Redmi Note 13 Pro
  • OS: Android 14

avdhootu27 avatar Apr 27 '24 13:04 avdhootu27

The keyboard also does not appear for me on mobile browsers on iOS.

jblankenship5 avatar Jul 10 '24 04:07 jblankenship5

Hi @jblankenship5, can you check if the autofocus works if you replace Pinput with:

    return TextField(
      autofocus: true,
    );

Tkko avatar Jul 10 '24 07:07 Tkko

No it does not @Tkko, after some research I've come to realize that autofocus doesn't work at all on mobile browsers on iOS. I guess the OS requires the user to tap on the screen or give some kind of input. For this reason I have turned auto focus off for iOS browsers, and that includes all the other form widgets in my app.

jblankenship5 avatar Jul 10 '24 08:07 jblankenship5