From aed4311579d845fbd8a0a29e487f412e4105b6f1 Mon Sep 17 00:00:00 2001 From: f-person Date: Thu, 16 Dec 2021 18:05:32 +0400 Subject: [PATCH] Request keyboard focus when no child is found `getRenderEditor()!.selectWordEdge` and `getRenderEditor().selectPosition` currently throw a `'No child'` which prevents the field from focusing. This happens when `minHeight` is set and the whole field is not filled with content from the editor (e. g. it's empty or only one line has some data). This change catches the `'No child'` exception and lets the code to continue its execution and request field focus. --- lib/src/widgets/editor.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/src/widgets/editor.dart b/lib/src/widgets/editor.dart index 0cbffe10..a14fa082 100644 --- a/lib/src/widgets/editor.dart +++ b/lib/src/widgets/editor.dart @@ -599,16 +599,22 @@ class _QuillEditorSelectionGestureDetectorBuilder break; case PointerDeviceKind.touch: case PointerDeviceKind.unknown: - getRenderEditor()!.selectWordEdge(SelectionChangedCause.tap); - break; + try { + getRenderEditor()!.selectWordEdge(SelectionChangedCause.tap); + } finally { + break; + } } break; case TargetPlatform.android: case TargetPlatform.fuchsia: case TargetPlatform.linux: case TargetPlatform.windows: - getRenderEditor()!.selectPosition(SelectionChangedCause.tap); - break; + try { + getRenderEditor()!.selectPosition(SelectionChangedCause.tap); + } finally { + break; + } } } _state._requestKeyboard();