Skip to content

Fix tag value reappearing after clearing and pressing Done#104

Merged
stopflock merged 3 commits intoFoggedLens:mainfrom
dougborg:fix/tag-value-clear-on-done
Feb 11, 2026
Merged

Fix tag value reappearing after clearing and pressing Done#104
stopflock merged 3 commits intoFoggedLens:mainfrom
dougborg:fix/tag-value-clear-on-done

Conversation

@dougborg
Copy link
Collaborator

@dougborg dougborg commented Feb 11, 2026

Summary

  • Bug: Clearing a tag value field on the Refine Tags page and pressing "Done" causes the value to reappear (auto-selects the first NSI suggestion)
  • Root cause: RawAutocomplete.onFieldSubmitted auto-selects the first option when called — designed for desktop Enter key, not mobile Done. Since optionsBuilder returns all suggestions when text is empty, pressing Done on an empty field triggers auto-selection of the first suggestion.
  • Fix: Guard onFieldSubmitted on non-empty text. When Done is pressed on an empty field, fire an onCleared callback instead — callers use this to prompt for tag removal since empty tags are not useful.
  • Scope: Profile editor, operator profile editor, and additional existing tags on the refine sheet all prompt to remove the tag. Refinable tags (which start empty by design) are unaffected.

Test plan

  • 4 widget tests verify the onSubmitted guard and onCleared callback behavior
  • Full test suite passes (45 tests, no regressions)
  • Manual: clear a tag value, press Done — confirmation dialog appears offering to remove the tag
  • Manual: clear a refinable tag value, press Done — field stays empty, no dialog

🤖 Generated with Claude Code

dougborg and others added 2 commits February 10, 2026 18:56
RawAutocomplete.onFieldSubmitted auto-selects the first option when
called, which means pressing "Done" on an empty tag value field
re-populates it with the first NSI suggestion. These tests prove the
bug exists (unguarded path) and verify the fix (guarded path).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…appearing

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>
Copilot AI review requested due to automatic review settings February 11, 2026 01:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a mobile keyboard “Done” submission edge case in the NSI tag value autocomplete field where clearing the input and submitting would inadvertently re-select the first suggestion.

Changes:

  • Guard RawAutocomplete’s onFieldSubmitted call so it only runs when the text is non-empty.
  • Add widget tests that reproduce the buggy behavior and verify the guarded behavior.
  • Add a widget test ensuring autocomplete still completes when partial text is present.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/widgets/nsi_tag_value_field.dart Prevents empty-submit from auto-selecting the first NSI suggestion by guarding onSubmitted.
test/widgets/nsi_tag_value_field_test.dart Adds regression tests for the empty-submit bug, the fix, and a partial-text autocomplete scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The RawAutocomplete tests proved the pattern and fix but never
instantiated NSITagValueField itself — no actual coverage gained.
PR FoggedLens#36 replaces the widget entirely, so investing in testability
here isn't worthwhile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@stopflock stopflock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank goodness. Approve approve approve lol

@stopflock stopflock merged commit c8e396a into FoggedLens:main Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants