From 7bd9740c8fe614c9762fe4772376b21841f6665a Mon Sep 17 00:00:00 2001 From: dreautall <109872040+dreautall@users.noreply.github.com> Date: Sat, 14 Oct 2023 19:16:47 +0000 Subject: [PATCH] only send DismissIntent when text field is focused --- lib/widgets/autocompletetext.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/widgets/autocompletetext.dart b/lib/widgets/autocompletetext.dart index de1c0f02..7d600df2 100644 --- a/lib/widgets/autocompletetext.dart +++ b/lib/widgets/autocompletetext.dart @@ -73,9 +73,14 @@ class AutoCompleteText extends StatelessWidget { style: disabled ? style?.copyWith(color: Theme.of(context).disabledColor) : style, - onTapOutside: (_) => Actions.invoke( - FocusManager.instance.primaryFocus?.context ?? context, - const DismissIntent()), + onTapOutside: (_) { + final BuildContext? ctx = + FocusManager.instance.primaryFocus?.context; + if (!focusNode.hasFocus || ctx == null) { + return; + } + Actions.invoke(ctx, const DismissIntent()); + }, ), optionsViewBuilder: (BuildContext context, void Function(T) onOptionSelected, Iterable options) =>