-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
[Linux][Web]: Bug while pressing Numeric Keypad keys on web with Flutter last stable version #148447
Comments
After several attempts: Traditional number keys work as expected, this is only happening with the Numeric Keypad. |
Thanks for the report @flrnsbt |
Yes I'm using a physical keyboard |
Only tested on Web. |
That was working perfectly fine before I upgrade flutter. It was working on 3.16.9 |
I can reproduce it on web chrome or firefox with this code: import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
builder: (context, child) {
return const _Test();
},
);
}
}
class _Test extends StatelessWidget {
const _Test({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(body: Center(child: TextField()));
}
} |
It seems that if any key other than 012346789 is pressed while pressing a digit key it works. |
Maybe related? #148406 |
Thanks for the update @flrnsbt flutter channel master |
I've just tried it, but the problem is still there. [✓] Flutter (Channel master, 3.22.0-36.0.pre.37, on Ubuntu 23.10 6.5.0-35-generic, locale en_US.UTF-8)
• Flutter version 3.22.0-36.0.pre.37 on channel master at /home/florian/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7f32df4218 (21 minutes ago), 2024-05-17 01:57:22 -0400
• Engine revision d575e511f9
• Dart version 3.5.0 (build 3.5.0-164.0.dev)
• DevTools version 2.36.0-dev.10
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /home/florian/Android/Sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /home/florian/Android/Sdk
• Java binary at: /home/florian/android-studio/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 16.0.6 (15)
• cmake version 3.27.4
• ninja version 1.11.1
• pkg-config version 1.8.1
[!] Android Studio (version unknown)
• Android Studio at /home/florian/android-studio
• 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
✗ Unable to determine Android Studio version.
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.89.1)
• VS Code at /snap/code/current/usr/share/code
• Flutter extension version 3.88.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 23.10 6.5.0-35-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.207
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category. |
It seems to be web-specific, as native Linux doesn't have this issue. |
Thanks for the update. I tried running sample TextField() on web using mac desktop and entering numeric data using physical keyboard, but didn't observed the reported error. Looks like it is specific to Linux + chrome setup. Also, going by @flrnsbt's observation that it didn't occur in previous stable (3.19.6) but occuring in 3.22.0, I'll label this as regression and for team's input / attention. |
The |
Confirming the bug in Linux Web (both Chrome and Firefox). Couldn't reproduce in MacBook. |
Same issue Linux+Chrome v3.22.0 |
I can't reproduce the error above but I can see the result at #148447 (comment) on my Linux machine in which only 0 and 5 keys are written out (same result to a deduplicated issue at #148544). I reproduced this on Flutter Web target platform with a keyboard with numpad keys. This doesn't occur on Flutter Linux app and Flutter Web target on macOS machine. The issue doesn't appear on the previous Flutter stable release 3.19.6. flutter doctor -v (stable & master)[✓] Flutter (Channel stable, 3.22.0, on Ubuntu 22.04.3 LTS 6.5.0-26-generic, locale en_US.UTF-8)
• Flutter version 3.22.0 on channel stable at /home/huynq/Documents/Working/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5dcb86f68f (11 days ago), 2024-05-09 07:39:20 -0500
• Engine revision f6344b75dc
• Dart version 3.4.0
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc3)
• Android SDK at /home/huynq/Android/Sdk/
• Platform android-33, build-tools 34.0.0-rc3
• Java binary at: /snap/android-studio/current/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 14.0.0-1ubuntu1.1
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2
[✓] Android Studio (version 2021.1)
• Android Studio at /home/huynq/Documents/android-studio
• Flutter plugin version 67.0.1
• Dart plugin version 211.7817
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[!] Android Studio (version unknown)
• Android Studio at /snap/android-studio/current
• 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
✗ Unable to determine Android Studio version.
• android-studio-dir = /snap/android-studio/current
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
[✓] VS Code (version 1.84.2)
• VS Code at /usr/share/code
• Flutter extension version 3.86.0
[✓] VS Code (version 1.88.1)
• VS Code at /snap/code/current/usr/share/code
• Flutter extension version 3.86.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.3 LTS 6.5.0-26-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.199
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.22.0-36.0.pre.54, on Ubuntu 22.04.3 LTS 6.5.0-26-generic, locale en_US.UTF-8)
• Flutter version 3.22.0-36.0.pre.54 on channel master at /home/huynq/Documents/Working/flutter_master
! Warning: `flutter` on your path resolves to /home/huynq/Documents/Working/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /home/huynq/Documents/Working/flutter_master. Consider adding /home/huynq/Documents/Working/flutter_master/bin to the front of your path.
! Warning: `dart` on your path resolves to /home/huynq/Documents/Working/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /home/huynq/Documents/Working/flutter_master. Consider adding /home/huynq/Documents/Working/flutter_master/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 414d923872 (3 hours ago), 2024-05-19 21:58:34 -0400
• Engine revision c6fecf65fb
• Dart version 3.5.0 (build 3.5.0-169.0.dev)
• DevTools version 2.36.0-dev.10
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc3)
• Android SDK at /home/huynq/Android/Sdk/
• Platform android-33, build-tools 34.0.0-rc3
• Java binary at: /snap/android-studio/current/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 14.0.0-1ubuntu1.1
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2
[✓] Android Studio (version 2021.1)
• Android Studio at /home/huynq/Documents/android-studio
• Flutter plugin version 67.0.1
• Dart plugin version 211.7817
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[!] Android Studio (version unknown)
• Android Studio at /snap/android-studio/current
• 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
✗ Unable to determine Android Studio version.
• android-studio-dir = /snap/android-studio/current
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
[✓] VS Code (version 1.84.2)
• VS Code at /usr/share/code
• Flutter extension version 3.88.0
[✓] VS Code (version 1.88.1)
• VS Code at /snap/code/current/usr/share/code
• Flutter extension version 3.88.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.3 LTS 6.5.0-26-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.199
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 2 categories. Updating issue's labels as it seems more of a text input than web issue but still forward information to web team. |
@darshankawar Numeric keys from Numpad in web app in linux web browsers only not working this is because after this PR #145464 bug after this commit hash: 859eb2enumeric keys work in linux web, if using previous commit: 5fab92ffile path: flutter/lib/src/widgets/default_text_editing_shortcuts.dartline No: 255 to 297 static final Map<ShortcutActivator, Intent> _linuxNumpadShortcuts = <ShortcutActivator, Intent>{
// When numLock is on, numpad keys shortcuts require shift to be pressed too.
const SingleActivator(LogicalKeyboardKey.numpad6, shift: true, numLock: LockState.locked): const ExtendSelectionByCharacterIntent(forward: true, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad4, shift: true, numLock: LockState.locked): const ExtendSelectionByCharacterIntent(forward: false, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad8, shift: true, numLock: LockState.locked): const ExtendSelectionVerticallyToAdjacentLineIntent(forward: false, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad2, shift: true, numLock: LockState.locked): const ExtendSelectionVerticallyToAdjacentLineIntent(forward: true, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad6, shift: true, control: true, numLock: LockState.locked): const ExtendSelectionToNextWordBoundaryIntent(forward: true, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad4, shift: true, control: true, numLock: LockState.locked): const ExtendSelectionToNextWordBoundaryIntent(forward: false, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad8, shift: true, control: true, numLock: LockState.locked): const ExtendSelectionToNextParagraphBoundaryIntent(forward: false, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad2, shift: true, control: true, numLock: LockState.locked): const ExtendSelectionToNextParagraphBoundaryIntent(forward: true, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad9, shift: true, numLock: LockState.locked): const ExtendSelectionVerticallyToAdjacentPageIntent(forward: false, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad3, shift: true, numLock: LockState.locked): const ExtendSelectionVerticallyToAdjacentPageIntent(forward: true, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad7, shift: true, numLock: LockState.locked): const ExtendSelectionVerticallyToAdjacentLineIntent(forward: false, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpad1, shift: true, numLock: LockState.locked): const ExtendSelectionVerticallyToAdjacentLineIntent(forward: true, collapseSelection: false),
const SingleActivator(LogicalKeyboardKey.numpadDecimal, shift: true, numLock: LockState.locked): const DeleteCharacterIntent(forward: true),
const SingleActivator(LogicalKeyboardKey.numpadDecimal, shift: true, control: true, numLock: LockState.locked): const DeleteToNextWordBoundaryIntent(forward: true),
// When numLock is off, numpad keys shortcuts require shift not to be pressed.
const SingleActivator(LogicalKeyboardKey.numpad6, numLock: LockState.unlocked): const ExtendSelectionByCharacterIntent(forward: true, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad4, numLock: LockState.unlocked): const ExtendSelectionByCharacterIntent(forward: false, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad8, numLock: LockState.unlocked): const ExtendSelectionVerticallyToAdjacentLineIntent(forward: false, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad2, numLock: LockState.unlocked): const ExtendSelectionVerticallyToAdjacentLineIntent(forward: true, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad6, control: true, numLock: LockState.unlocked): const ExtendSelectionToNextWordBoundaryIntent(forward: true, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad4, control: true, numLock: LockState.unlocked): const ExtendSelectionToNextWordBoundaryIntent(forward: false, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad8, control: true, numLock: LockState.unlocked): const ExtendSelectionToNextParagraphBoundaryIntent(forward: false, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad2, control: true, numLock: LockState.unlocked): const ExtendSelectionToNextParagraphBoundaryIntent(forward: true, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad9, numLock: LockState.unlocked): const ExtendSelectionVerticallyToAdjacentPageIntent(forward: false, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad3, numLock: LockState.unlocked): const ExtendSelectionVerticallyToAdjacentPageIntent(forward: true, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad7, numLock: LockState.unlocked): const ExtendSelectionVerticallyToAdjacentLineIntent(forward: false, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpad1, numLock: LockState.unlocked): const ExtendSelectionVerticallyToAdjacentLineIntent(forward: true, collapseSelection: true),
const SingleActivator(LogicalKeyboardKey.numpadDecimal, numLock: LockState.unlocked): const DeleteCharacterIntent(forward: true),
const SingleActivator(LogicalKeyboardKey.numpadDecimal, control: true, numLock: LockState.unlocked): const DeleteToNextWordBoundaryIntent(forward: true),
}; |
Seems that when starting the app with numLock off then turning it on everything works fine. I managed to make things work as expected by editing the line at 140 in file @override
bool isModifierPressed(ModifierKey key, {KeyboardSide side = KeyboardSide.any}) {
return isPressed = switch (key) {
ModifierKey.controlModifier => metaState & modifierControl != 0,
ModifierKey.shiftModifier => metaState & modifierShift != 0,
ModifierKey.altModifier => metaState & modifierAlt != 0,
ModifierKey.metaModifier => metaState & modifierMeta != 0,
ModifierKey.numLockModifier => true,
ModifierKey.capsLockModifier => metaState & modifierCapsLock != 0,
ModifierKey.scrollLockModifier => metaState & modifierScrollLock != 0,
// On Web, the browser doesn't report the state of the FN and SYM modifiers.
ModifierKey.functionModifier || ModifierKey.symbolModifier => false,
};
} But i get this exception: |
## Description This PRs fixes a Web issue on Linux related to numpad keys. In #145464, I introduced numpad shortcuts for Linux. These shortcuts work well on a desktop Linux application but they broke the Linux+Web numpad logic. When I added these shortcuts, I expected them to not be active on Web (because I knew that on Web, those shortcuts are handled by the browser). But there is a trick: text editing shortcuts are still defined on Web but they are disabled at the editable text level so one can use them in components that are not `EditableText` (see #103377). In this PR, I used the same approach than for other text editing shortcuts: when on web associate those shortcuts to the `DoNothingAndStopPropagationTextIntent` intent. ## Related Issue Fixes #148447. ## Tests Updates 2 tests. Adds 2 tests.
## Description This PRs fixes a Web issue on Linux related to numpad keys. In flutter#145464, I introduced numpad shortcuts for Linux. These shortcuts work well on a desktop Linux application but they broke the Linux+Web numpad logic. When I added these shortcuts, I expected them to not be active on Web (because I knew that on Web, those shortcuts are handled by the browser). But there is a trick: text editing shortcuts are still defined on Web but they are disabled at the editable text level so one can use them in components that are not `EditableText` (see flutter#103377). In this PR, I used the same approach than for other text editing shortcuts: when on web associate those shortcuts to the `DoNothingAndStopPropagationTextIntent` intent. ## Related Issue Fixes flutter#148447. ## Tests Updates 2 tests. Adds 2 tests.
Steps to reproduce
Use the numeric keypad with any EditableText widget
Expected results
Numbers should be correctly entered in the field, instead an error is thrown.
This only happens with digits from the numeric keypad.
Actual results
Code sample
Code sample
[Paste your code here]
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: