Fix certain keys not working on web when editor is a child of a scroll view (#304) (#618)

Co-authored-by: Nicolas Dion Bouchard <nicolas.dionbouchard@sviesolutions.com>
pull/620/head
Nicolas Dion-Bouchard 3 years ago committed by GitHub
parent 2b1a13b052
commit d0bcca76e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      lib/src/widgets/editor.dart

@ -469,10 +469,26 @@ class QuillEditorState extends State<QuillEditor>
floatingCursorDisabled: widget.floatingCursorDisabled,
);
return _selectionGestureDetectorBuilder.build(
final editor = _selectionGestureDetectorBuilder.build(
behavior: HitTestBehavior.translucent,
child: child,
);
if (kIsWeb) {
// Intercept RawKeyEvent on Web to prevent it from propagating to parents
// that might interfere with the editor key behavior, such as
// SingleChildScrollView. Thanks to @wliumelb for the workaround.
// See issue https://github.com/singerdmx/flutter-quill/issues/304
return RawKeyboardListener(
onKey: (_) {},
focusNode: FocusNode(
onKey: (node, event) => KeyEventResult.skipRemainingHandlers,
),
child: editor,
);
}
return editor;
}
@override

Loading…
Cancel
Save