Skip to content

Commit

Permalink
only send DismissIntent when text field is focused
Browse files Browse the repository at this point in the history
  • Loading branch information
dreautall committed Oct 14, 2023
1 parent 3f60e22 commit 7bd9740
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/widgets/autocompletetext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ class AutoCompleteText<T extends Object> 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<T> options) =>
Expand Down

0 comments on commit 7bd9740

Please sign in to comment.