-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#46032Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Create a shortcut using FocusableActionDetector.
- Use the shortcuts to alternate the focus between TextField and other widgets.
I created and tested the Mac app on macOS. It has not been verified on other operating systems.
Note that the focus between TextFields seems to work fine.
Expected results
Smooth focus transition is achieved.
Actual results
Focus is not being moved.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(home: MyHomePage());
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({super.key});
final _focus1 = FocusNode();
final _focus2 = FocusNode();
@override
Widget build(BuildContext context) {
return Scaffold(
body: FocusableActionDetector(
shortcuts: {
LogicalKeySet(
LogicalKeyboardKey.meta,
LogicalKeyboardKey.digit1,
): const KeyIntent(1),
LogicalKeySet(
LogicalKeyboardKey.meta,
LogicalKeyboardKey.digit2,
): const KeyIntent(2),
},
actions: {
KeyIntent: CallbackAction(onInvoke: (Intent intent) {
if (intent is KeyIntent) {
print(intent.key);
if (intent.key == 1) {
_focus1.requestFocus();
} else {
_focus2.requestFocus();
}
}
return null;
})
},
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
autofocus: true,
focusNode: _focus1,
),
// TextField(
// focusNode: _focus2,
// ),
// TextButton(
// focusNode: _focus1,
// autofocus: true,
// onPressed: () {},
// child: const Text("abc"),
// ),
TextButton(
focusNode: _focus2,
onPressed: () {},
child: const Text("abc"),
),
],
),
),
),
);
}
}
class KeyIntent extends Intent {
final int key;
const KeyIntent(this.key);
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.13.2, on macOS 13.5.1 22G90 darwin-arm64, locale ja-JP)
• Flutter version 3.13.2 on channel stable at /Users/zuvola/Documents/Tools/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ff5b5b5fa6 (8 days ago), 2023-08-24 08:12:28 -0500
• Engine revision b20183e040
• Dart version 3.1.0
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/zuvola/Library/Android/sdk
• Platform android-33, build-tools 33.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• 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.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.81.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.70.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.5.1 22G90 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.140
[✓] Network resources
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team