Skip to content

fix(dance-editor): clear tag input after committing a tag (#402)#421

Merged
ibanner56 merged 3 commits into
mainfrom
isaacbanner-fix-tag-input-clear-402
Jul 21, 2026
Merged

fix(dance-editor): clear tag input after committing a tag (#402)#421
ibanner56 merged 3 commits into
mainfrom
isaacbanner-fix-tag-input-clear-402

Conversation

@ibanner56

Copy link
Copy Markdown
Owner

Fixes #402. In the dance editor's Tags field, after a typed value was converted into a tag pill, the text field kept showing the committed text — making it awkward to add several tags in a row. The input now clears after each tag is committed and keeps focus.

Root cause

The Tags field is the shared NamePicker widget, whose _AddAutocomplete uses Flutter's Autocomplete. On commit, Flutter's RawAutocomplete._select sets the field controller text to the selected option's label before invoking our onSelected, and the widget never cleared it. All commit paths (tapping a dropdown option, and Enter/submit) funnel through onSelected.

Fix

  • _AddAutocomplete is now a StatefulWidget that owns (and disposes) its own TextEditingController and FocusNode, passed to Autocomplete.
  • In onSelected, only after a tag is successfully committed (create path: after await onCreate succeeds and onAdd runs), the field is cleared and focus re-requested.
  • Clearing lives solely in onSelected, so empty/duplicate/no-op submits leave state untouched; a thrown onCreate short-circuits before any clear.
  • The shared widget also gives the Authors field the same consistent clear-on-commit behavior.

Minimal, surgical — no editor refactor; compendium_core stays Flutter-free (app-only change).

Tests

Extended app/test/dance_editor_screen_test.dart:

  • Committing a tag clears tag-input, keeps focus, supports back-to-back adds.
  • Creating a new tag inline clears the input.
  • An empty/whitespace entry adds no chip and leaves the field usable.

Validation gates

  • fvm dart format . — 0 changed
  • fvm flutter analyze (core + app) — No issues found
  • core fvm dart test — 1798 passed, 4 skipped
  • app fvm flutter test — 1648 passed

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

Flutter's Autocomplete filled the field with the selected option's label
before onSelected ran, so the typed text lingered after a tag pill was
added, making back-to-back tag entry awkward.

_AddAutocomplete now owns its TextEditingController and FocusNode and, only
after a tag is successfully committed, clears the field and re-requests
focus. Empty/duplicate/no-op submits never reach onSelected, so they leave
state untouched. The shared NamePicker also gives the Authors field the same
consistent clear-on-commit behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 00:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #402 in the dance editor where committing a tag left the committed text in the Tags input, making it awkward to add multiple tags. It updates the shared NamePicker autocomplete so the input clears and focus is retained after a successful commit, and adds widget tests to lock in the behavior.

Changes:

  • Refactors _AddAutocomplete to a StatefulWidget that owns a TextEditingController and FocusNode, enabling reliable clearing/refocus after selection.
  • Clears the autocomplete text field and re-requests focus after a successful selection/creation via onSelected.
  • Adds/extends dance editor widget tests covering clear-on-commit, back-to-back adds, inline creation, and whitespace-only no-op behavior.

Reviewed changes

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

File Description
app/lib/src/screens/dance_editor/name_picker.dart Makes the shared autocomplete field stateful so it can clear text and keep focus after committing a choice.
app/test/dance_editor_screen_test.dart Adds widget tests ensuring tag commit clears the field and remains usable across multiple commits and edge cases.

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

Comment thread app/lib/src/screens/dance_editor/name_picker.dart
Comment thread app/test/dance_editor_screen_test.dart Outdated
ibanner56 and others added 2 commits July 20, 2026 17:44
Address Copilot review on #421:
- Add `if (!mounted) return;` after awaiting onCreate so a disposed
  controller/focus node is never touched when the editor closes mid-create.
- Assert the specific tag chip is absent (not any Chip) in the empty-entry
  test so unrelated chips (e.g. tune chips) can't mask a regression.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…clear-on-commit

Follow-up to review on #421:
- Add a NamePicker unit test that disposes the picker while onCreate is still
  in flight, then resolves it, asserting no disposed-controller exception and
  that the !mounted guard short-circuits before onAdd/clear.
- Add an Authors-field test pinning that the shared picker also clears the
  input and keeps focus on commit, so the shared-widget guarantee can't
  silently regress for one field but not the other.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@ibanner56
ibanner56 merged commit 80e3ca3 into main Jul 21, 2026
7 checks passed
@ibanner56
ibanner56 deleted the isaacbanner-fix-tag-input-clear-402 branch July 21, 2026 01:11
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.

[Bug]: When adding a tag, the text edit doesn't clear after converting text into a pill tag

2 participants