mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-02-12 08:42:51 +00:00
Guard onFieldSubmitted on non-empty text to prevent cleared values reappearing
When a user clears a tag value and presses Done, RawAutocomplete's onFieldSubmitted auto-selects the first option from the suggestions list. Since optionsBuilder returns all suggestions for empty text, this causes the cleared value to reappear. Guarding the call on non-empty text prevents the auto-selection while preserving autocomplete behavior when the user has typed a partial match. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -132,7 +132,14 @@ class _NSITagValueFieldState extends State<NSITagValueField> {
|
||||
onChanged: (value) {
|
||||
widget.onChanged(value);
|
||||
},
|
||||
onSubmitted: (_) => onFieldSubmitted(),
|
||||
onSubmitted: (_) {
|
||||
// Only auto-complete when there's text to match against.
|
||||
// Otherwise, pressing Done on an empty field would auto-select
|
||||
// the first suggestion, preventing users from clearing values.
|
||||
if (controller.text.isNotEmpty) {
|
||||
onFieldSubmitted();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
optionsViewBuilder: (
|
||||
|
||||
Reference in New Issue
Block a user