Unverified Commit 7f4bb1ee authored by Mouad Debbar's avatar Mouad Debbar Committed by GitHub

Use the shortcuts temporary solution only on web (#74768)

parent 7c0300a3
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle; import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle;
import 'package:flutter/foundation.dart' show defaultTargetPlatform; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
...@@ -1201,9 +1201,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio ...@@ -1201,9 +1201,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
), ),
); );
return Shortcuts( final Widget child = Semantics(
shortcuts: scrollShortcutOverrides,
child: Semantics(
enabled: enabled, enabled: enabled,
onTap: !enabled || widget.readOnly ? null : () { onTap: !enabled || widget.readOnly ? null : () {
if (!controller.selection.isValid) { if (!controller.selection.isValid) {
...@@ -1226,7 +1224,14 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio ...@@ -1226,7 +1224,14 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
), ),
), ),
), ),
),
); );
if (kIsWeb) {
return Shortcuts(
shortcuts: scrollShortcutOverrides,
child: child,
);
}
return child;
} }
} }
...@@ -1290,12 +1290,10 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements ...@@ -1290,12 +1290,10 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
semanticsMaxValueLength = null; semanticsMaxValueLength = null;
} }
return MouseRegion( child = MouseRegion(
cursor: effectiveMouseCursor, cursor: effectiveMouseCursor,
onEnter: (PointerEnterEvent event) => _handleHover(true), onEnter: (PointerEnterEvent event) => _handleHover(true),
onExit: (PointerExitEvent event) => _handleHover(false), onExit: (PointerExitEvent event) => _handleHover(false),
child: Shortcuts(
shortcuts: scrollShortcutOverrides,
child: IgnorePointer( child: IgnorePointer(
ignoring: !_isEnabled, ignoring: !_isEnabled,
child: AnimatedBuilder( child: AnimatedBuilder(
...@@ -1318,7 +1316,14 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements ...@@ -1318,7 +1316,14 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
), ),
), ),
), ),
),
); );
if (kIsWeb) {
return Shortcuts(
shortcuts: scrollShortcutOverrides,
child: child,
);
}
return child;
} }
} }
...@@ -58,15 +58,13 @@ const int _kObscureShowLatestCharCursorTicks = 3; ...@@ -58,15 +58,13 @@ const int _kObscureShowLatestCharCursorTicks = 3;
/// A map used to disable scrolling shortcuts in text fields. /// A map used to disable scrolling shortcuts in text fields.
/// ///
/// This is a temporary fix for: https://github.com/flutter/flutter/issues/74191 /// This is a temporary fix for: https://github.com/flutter/flutter/issues/74191
final Map<LogicalKeySet, Intent> scrollShortcutOverrides = kIsWeb final Map<LogicalKeySet, Intent> scrollShortcutOverrides = <LogicalKeySet, Intent>{
? <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.space): DoNothingAndStopPropagationIntent(), LogicalKeySet(LogicalKeyboardKey.space): DoNothingAndStopPropagationIntent(),
LogicalKeySet(LogicalKeyboardKey.arrowUp): DoNothingAndStopPropagationIntent(), LogicalKeySet(LogicalKeyboardKey.arrowUp): DoNothingAndStopPropagationIntent(),
LogicalKeySet(LogicalKeyboardKey.arrowDown): DoNothingAndStopPropagationIntent(), LogicalKeySet(LogicalKeyboardKey.arrowDown): DoNothingAndStopPropagationIntent(),
LogicalKeySet(LogicalKeyboardKey.arrowLeft): DoNothingAndStopPropagationIntent(), LogicalKeySet(LogicalKeyboardKey.arrowLeft): DoNothingAndStopPropagationIntent(),
LogicalKeySet(LogicalKeyboardKey.arrowRight): DoNothingAndStopPropagationIntent(), LogicalKeySet(LogicalKeyboardKey.arrowRight): DoNothingAndStopPropagationIntent(),
} };
: <LogicalKeySet, Intent>{};
/// A controller for an editable text field. /// A controller for an editable text field.
/// ///
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment