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

Arrow (also D-PAD) keys don't work for focus traversal of TextFormField #49335

Closed
malviyaritesh opened this issue Jan 23, 2020 · 6 comments
Closed
Labels
a: desktop Running on desktop f: focus Focus traversal, gaining or losing focus f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@malviyaritesh
Copy link

Thanks for the awesome framework.
I'm developing an app which should work on both Android mobile devices as well as Android TVs. I'm facing some issue while implementing login and signup forms.

Steps to Reproduce

  1. Run flutter create testpad.
  2. Update the main.dart as follows:
import 'package:flutter/material.dart';

void main() => runApp(TestApp());

class TestApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Test App'),
        ),
        body: SingleChildScrollView(
          padding: const EdgeInsets.all(8.0),
          child: TestWidget(),
        ),
      ),
    );
  }
}

class TestWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: List<Widget>.generate(5, (int index) => TextFormField(
        decoration: InputDecoration(
          labelText: 'Field ${index + 1}',
        ),
      )),
    );
  }
}
  1. Run app and try to change the focus with keyboard.

Expected results:
The focus should move to both next and previous fields on various key press events of keyboard and TV remotes, as it works as expected for focus traversal between other focusable widgets.
Also, when moving focus with Tab key, then the white-space is added to input field, which should not be the case.

Actual results:
The focus moves to next field with Tab key but previous field is not getting focus when Shift+Tab is pressed. Also neither arrow keys nor Android TV remote D-PAD keys works for focus traversal of TextFormField but works fine for other focusable widgets.

Logs
[  +21 ms] executing: [/home/ritesh/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +30 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 27321ebbad34b0a3fafe99fac037102196d655ff
[        ] executing: [/home/ritesh/flutter/] git describe --match v*.*.* --first-parent --long --tags
[   +8 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.12.13+hotfix.5-0-g27321ebba
[   +8 ms] executing: [/home/ritesh/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[   +7 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [/home/ritesh/flutter/] git ls-remote --get-url origin
[   +7 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +50 ms] executing: [/home/ritesh/flutter/] git rev-parse --abbrev-ref HEAD
[   +6 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +96 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb devices -l
[  +11 ms] Exit code 0 from: /home/ritesh/Android/Sdk/platform-tools/adb devices -l
[        ] List of devices attached
           emulator-5554          device product:sdk_gphone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:3
[  +32 ms] /home/ritesh/Android/Sdk/platform-tools/adb -s emulator-5554 shell getprop
[  +41 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[   +3 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +147 ms] Generating
/home/ritesh/Projects/flutter/testpad/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[  +29 ms] ro.hardware = ranchu
[  +27 ms] Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling
software rendering
           with "--enable-software-rendering".
[  +17 ms] Launching lib/main.dart on Android SDK built for x86 in debug mode...
[   +9 ms] executing: /home/ritesh/Android/Sdk/build-tools/28.0.3/aapt dump xmltree
/home/ritesh/Projects/flutter/testpad/build/app/outputs/apk/app.apk AndroidManifest.xml
[  +54 ms] Exit code 0 from: /home/ritesh/Android/Sdk/build-tools/28.0.3/aapt dump xmltree
/home/ritesh/Projects/flutter/testpad/build/app/outputs/apk/app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
               A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
               A: package="com.owliverse.testpad" (Raw: "com.owliverse.testpad")
               A: platformBuildVersionCode=(type 0x10)0x1c
               A: platformBuildVersionName=(type 0x10)0x9
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=22)
                 A: android:label(0x01010001)="testpad" (Raw: "testpad")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw:
                 "androidx.core.app.CoreComponentFactory")
                 E: activity (line=28)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.owliverse.testpad.MainActivity" (Raw: "com.owliverse.testpad.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: intent-filter (line=35)
                     E: action (line=36)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=38)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=45)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[   +8 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb -s emulator-5554 shell -x logcat -v time -s flutter
[   +6 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb version
[  +19 ms] Android Debug Bridge version 1.0.41
           Version 29.0.2-5738569
           Installed as /home/ritesh/Android/Sdk/platform-tools/adb
[   +3 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb start-server
[  +12 ms] Building APK
[  +27 ms] Running Gradle task 'assembleDebug'...
[   +2 ms] gradle.properties already sets `android.enableR8`
[   +3 ms] Using gradle from /home/ritesh/Projects/flutter/testpad/android/gradlew.
[   +4 ms] executing: /snap/android-studio/current/android-studio/jre/bin/java -version
[  +73 ms] Exit code 0 from: /snap/android-studio/current/android-studio/jre/bin/java -version
[        ] openjdk version "1.8.0_202-release"
           OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
           OpenJDK 64-Bit Server VM (build 25.202-b49-5587405, mixed mode)
[   +2 ms] executing: [/home/ritesh/Projects/flutter/testpad/android/] /home/ritesh/Projects/flutter/testpad/android/gradlew
-Pverbose=true -Ptarget=/home/ritesh/Projects/flutter/testpad/lib/main.dart -Ptrack-widget-creation=true
-Pfilesystem-scheme=org-dartlang-root -Ptarget-platform=android-x86 assembleDebug
[+2759 ms] > Task :app:compileFlutterBuildDebug UP-TO-DATE
[        ] > Task :app:packLibsflutterBuildDebug UP-TO-DATE
[        ] > Task :app:preBuild UP-TO-DATE
[        ] > Task :app:preDebugBuild UP-TO-DATE
[        ] > Task :app:compileDebugAidl NO-SOURCE
[        ] > Task :app:checkDebugManifest UP-TO-DATE
[        ] > Task :app:generateDebugBuildConfig UP-TO-DATE
[        ] > Task :app:compileDebugRenderscript NO-SOURCE
[  +56 ms] > Task :app:cleanMergeDebugAssets
[        ] > Task :app:mergeDebugShaders UP-TO-DATE
[        ] > Task :app:compileDebugShaders UP-TO-DATE
[        ] > Task :app:generateDebugAssets UP-TO-DATE
[        ] > Task :app:mergeDebugAssets
[ +299 ms] > Task :app:copyFlutterAssetsDebug
[        ] > Task :app:mainApkListPersistenceDebug UP-TO-DATE
[        ] > Task :app:generateDebugResValues UP-TO-DATE
[        ] > Task :app:generateDebugResources UP-TO-DATE
[        ] > Task :app:mergeDebugResources UP-TO-DATE
[  +98 ms] > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
[        ] > Task :app:processDebugJavaRes NO-SOURCE
[        ] > Task :app:processDebugManifest UP-TO-DATE
[        ] > Task :app:processDebugResources UP-TO-DATE
[        ] > Task :app:compileDebugKotlin UP-TO-DATE
[        ] > Task :app:javaPreCompileDebug UP-TO-DATE
[  +98 ms] > Task :app:compileDebugJavaWithJavac UP-TO-DATE
[        ] > Task :app:compileDebugSources UP-TO-DATE
[        ] > Task :app:mergeDebugJavaResource UP-TO-DATE
[        ] > Task :app:checkDebugDuplicateClasses UP-TO-DATE
[        ] > Task :app:desugarDebugFileDependencies UP-TO-DATE
[        ] > Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE
[        ] > Task :app:mergeExtDexDebug UP-TO-DATE
[        ] > Task :app:mergeDexDebug UP-TO-DATE
[        ] > Task :app:validateSigningDebug UP-TO-DATE
[        ] > Task :app:signingConfigWriterDebug UP-TO-DATE
[  +73 ms] > Task :app:mergeDebugJniLibFolders UP-TO-DATE
[        ] > Task :app:mergeDebugNativeLibs UP-TO-DATE
[        ] > Task :app:stripDebugDebugSymbols UP-TO-DATE
[        ] Compatible side by side NDK version was not found.
[        ] > Task :app:packageDebug UP-TO-DATE
[        ] > Task :app:assembleDebug UP-TO-DATE
[        ] BUILD SUCCESSFUL in 3s
[        ] 30 actionable tasks: 3 executed, 27 up-to-date
[ +338 ms] Running Gradle task 'assembleDebug'... (completed in 3.8s)
[  +76 ms] calculateSha: LocalDirectory: '/home/ritesh/Projects/flutter/testpad/build/app/outputs/apk'/app.apk
[  +51 ms] calculateSha: reading file took 50us
[ +577 ms] calculateSha: computing sha took 577us
[   +4 ms] ✓ Built build/app/outputs/apk/debug/app-debug.apk.
[   +2 ms] executing: /home/ritesh/Android/Sdk/build-tools/28.0.3/aapt dump xmltree
/home/ritesh/Projects/flutter/testpad/build/app/outputs/apk/app.apk AndroidManifest.xml
[  +11 ms] Exit code 0 from: /home/ritesh/Android/Sdk/build-tools/28.0.3/aapt dump xmltree
/home/ritesh/Projects/flutter/testpad/build/app/outputs/apk/app.apk AndroidManifest.xml
[   +1 ms] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
               A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
               A: package="com.owliverse.testpad" (Raw: "com.owliverse.testpad")
               A: platformBuildVersionCode=(type 0x10)0x1c
               A: platformBuildVersionName=(type 0x10)0x9
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=22)
                 A: android:label(0x01010001)="testpad" (Raw: "testpad")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw:
                 "androidx.core.app.CoreComponentFactory")
                 E: activity (line=28)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.owliverse.testpad.MainActivity" (Raw: "com.owliverse.testpad.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: intent-filter (line=35)
                     E: action (line=36)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=38)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=45)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[   +2 ms] Stopping app 'app.apk' on Android SDK built for x86.
[   +1 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb -s emulator-5554 shell am force-stop com.owliverse.testpad
[  +38 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb -s emulator-5554 shell pm list packages com.owliverse.testpad
[  +32 ms] package:com.owliverse.testpad
[   +4 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb -s emulator-5554 shell cat
/data/local/tmp/sky.com.owliverse.testpad.sha1
[  +59 ms] f398099a9f664ebe1811f65dae97da464c1f9f0b
[        ] Latest build already installed.
[        ] Android SDK built for x86 startApp
[   +2 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb -s emulator-5554 shell am start -a android.intent.action.RUN -f
0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez
verify-entry-points true com.owliverse.testpad/com.owliverse.testpad.MainActivity
[  +54 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.owliverse.testpad/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[ +763 ms] Observatory URL on device: http://127.0.0.1:40603/VXCD1bJFpXU=/
[   +1 ms] executing: /home/ritesh/Android/Sdk/platform-tools/adb -s emulator-5554 forward tcp:0 tcp:40603
[  +16 ms] 36633
[        ] Forwarded host port 36633 to device port 40603 for Observatory
[  +25 ms] Connecting to service protocol: http://127.0.0.1:36633/VXCD1bJFpXU=/
[ +444 ms] Successfully connected to service protocol: http://127.0.0.1:36633/VXCD1bJFpXU=/
[   +3 ms] Sending to VM service: getVM({})
[  +12 ms] Result: {type: VM, name: vm, architectureBits: 32, hostCPU: Android virtual processor, operatingSystem: android,
targetCPU: ia32, version: 2.7.0 (Mon Dec 2 20:10:59 2019 +0100) on "android_ia32", _profilerMode: VM, _nativeZoneMemoryUsage: 0,
pid: 15211, s...
[  +10 ms] Sending to VM service: getIsolate({isolateId: isolates/2179448746185555})
[   +8 ms] Sending to VM service: _flutter.listViews({})
[  +23 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0xe2679710, isolate: {type: @Isolate,
fixedId: true, id: isolates/2179448746185555, name: main.dart$main-2179448746185555, number: 2179448746185555}}]}
[   +9 ms] DevFS: Creating new filesystem on the device (null)
[   +2 ms] Sending to VM service: _createDevFS({fsName: testpad})
[   +3 ms] Result: {type: Isolate, id: isolates/2179448746185555, name: main, number: 2179448746185555, _originNumber:
2179448746185555, startTime: 1579763153257, _heaps: {new: {type: HeapSpace, name: new, vmName: Scavenger, collections: 1,
avgCollectionPeriodMillis...
[  +60 ms] Result: {type: FileSystem, name: testpad, uri:
file:///data/user/0/com.owliverse.testpad/code_cache/testpadJLUCZQ/testpad/}
[        ] DevFS: Created new filesystem on the device
(file:///data/user/0/com.owliverse.testpad/code_cache/testpadJLUCZQ/testpad/)
[   +3 ms] Updating assets
[ +134 ms] Syncing files to device Android SDK built for x86...
[   +1 ms] Scanning asset files
[   +1 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[  +13 ms] /home/ritesh/flutter/bin/cache/dart-sdk/bin/dart
/home/ritesh/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root
/home/ritesh/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --target=flutter
-Ddart.developer.causal_async_stacks=true --output-dill /tmp/flutter_tool.WSYYTP/app.dill --packages
/home/ritesh/Projects/flutter/testpad/.packages -Ddart.vm.profile=false -Ddart.vm.product=false
--bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,avoid-closure-c
all-instructions --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root
[  +18 ms] <- compile package:testpad/main.dart
[+6620 ms] Updating files
[ +105 ms] DevFS: Sync finished
[   +3 ms] Syncing files to device Android SDK built for x86... (completed in 6,763ms, longer than expected)
[        ] Synced 0.9MB.
[   +1 ms] Sending to VM service: _flutter.listViews({})
[   +3 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0xe2679710, isolate: {type: @Isolate,
fixedId: true, id: isolates/2179448746185555, name: main.dart$main-2179448746185555, number: 2179448746185555}}]}
[   +1 ms] <- accept
[        ] Connected to _flutterView/0xe2679710.
[   +8 ms] 🔥  To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
[        ] An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:36633/VXCD1bJFpXU=/
[        ] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
Analyzing testpad...                                                    
No issues found! (ran in 11.7s)
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale en_IN)
    • Flutter version 1.12.13+hotfix.5 at /home/ritesh/flutter
    • Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

 
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/ritesh/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /snap/android-studio/current/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[✓] Android Studio (version 3.5)
    • Android Studio at /snap/android-studio/81/android-studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[!] Android Studio
    • Android Studio at /snap/android-studio/current/android-studio
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • android-studio-dir = /snap/android-studio/current/android-studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

! Doctor found issues in 2 categories.
@malviyaritesh malviyaritesh changed the title Shift+Tab and arrow (also D-PAD) keys doesn't work for focus traversal of TextFormField Shift+Tab and arrow (also D-PAD) keys don't work for focus traversal of TextFormField Jan 23, 2020
@VladyslavBondarenko VladyslavBondarenko added f: focus Focus traversal, gaining or losing focus framework flutter/packages/flutter repository. See also f: labels. platform-android Android applications specifically labels Jan 23, 2020
@HansMuller HansMuller added the f: material design flutter/packages/flutter/material repository. label Jan 24, 2020
@HansMuller
Copy link
Contributor

CC @gspencergoog

@gspencergoog
Copy link
Contributor

This is partially a duplicate of #47156 (the tab key shouldn't be entered when moving to the next field).

When I run this, both Tab and Shift-Tab function as expected for me, except for adding the tab to the field.

The DPAD navigation doesn't work because the DPAD input is interpreted as arrow key presses, and arrow keys on text fields move the cursor, not the focus. I agree that there should be a way to select this behavior, of course, and there isn't currently. Once we've converted the text fields to use Actions internally, this should be possible.

@gspencergoog gspencergoog added a: desktop Running on desktop and removed platform-android Android applications specifically labels Jan 24, 2020
@gspencergoog gspencergoog changed the title Shift+Tab and arrow (also D-PAD) keys don't work for focus traversal of TextFormField Arrow (also D-PAD) keys don't work for focus traversal of TextFormField Jan 24, 2020
@gspencergoog
Copy link
Contributor

You can solve this (partially) by supplying different default shortcuts for the WidgetsApp (or MaterialApp or CupertinoApp, depending on what you're using):

class TestApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      shortcuts: Map<LogicalKeySet, Intent>.from(WidgetsApp.defaultShortcuts)..addAll(<LogicalKeySet, Intent>{
        LogicalKeySet(LogicalKeyboardKey.arrowLeft): const DirectionalFocusIntent(TraversalDirection.left, ignoreTextFields: false),
        LogicalKeySet(LogicalKeyboardKey.arrowRight): const DirectionalFocusIntent(TraversalDirection.right, ignoreTextFields: false),
        LogicalKeySet(LogicalKeyboardKey.arrowDown): const DirectionalFocusIntent(TraversalDirection.down, ignoreTextFields: false),
        LogicalKeySet(LogicalKeyboardKey.arrowUp): const DirectionalFocusIntent(TraversalDirection.up, ignoreTextFields: false),
      }),
      home: Scaffold(
        appBar: AppBar(
          title: Text('Test App'),
        ),
        body: SingleChildScrollView(
          padding: const EdgeInsets.all(8.0),
          child: TestWidget(),
        ),
      ),
    );
  }
}

I say "partially", because it will still try and move the cursor inside the text field when you move to the next field unless they are single line fields where you're only moving vertically (like in your example).

@malviyaritesh
Copy link
Author

You can see that Shift+Tab key doesn't focus the previous TextFormField:

tabrecord

I noticed that the Shift+Tab doesn't work in Contacts app also, so I guess, its a problem with the Android emulator. Also, I'm not very much concerned about focus navigation with Tab as I'm not developing for Desktop yet.

But I do need support for focus navigation using arrow (and D-PAD) keys. Since shortcuts property is not yet available for MaterialApp widget in stable channel, I had tried wrapping the fields in Shortcuts widget but that was also not working as I was not aware about the ignoreTextFields property.
Anyways, but now I've solution. Thanks for your instant help.

@gspencergoog
Copy link
Contributor

Shift+Tab is not expected to work in an emulator, because it doesn't set the modifier bits on key events properly. It will work on a device.

The remaining issues in this bug are a duplicate of #47156, so I'm going to close this issue.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: desktop Running on desktop f: focus Focus traversal, gaining or losing focus f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
Desktop Features
  
Awaiting triage
Development

No branches or pull requests

4 participants