fix(dance-editor): clear tag input after committing a tag (#402)#421
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
_AddAutocompleteto aStatefulWidgetthat owns aTextEditingControllerandFocusNode, 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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
NamePickerwidget, whose_AddAutocompleteuses Flutter'sAutocomplete. On commit, Flutter'sRawAutocomplete._selectsets the field controller text to the selected option's label before invoking ouronSelected, and the widget never cleared it. All commit paths (tapping a dropdown option, and Enter/submit) funnel throughonSelected.Fix
_AddAutocompleteis now aStatefulWidgetthat owns (and disposes) its ownTextEditingControllerandFocusNode, passed toAutocomplete.onSelected, only after a tag is successfully committed (create path: afterawait onCreatesucceeds andonAddruns), the field is cleared and focus re-requested.onSelected, so empty/duplicate/no-op submits leave state untouched; a thrownonCreateshort-circuits before any clear.Minimal, surgical — no editor refactor;
compendium_corestays Flutter-free (app-only change).Tests
Extended
app/test/dance_editor_screen_test.dart:tag-input, keeps focus, supports back-to-back adds.Validation gates
fvm dart format .— 0 changedfvm flutter analyze(core + app) — No issues foundfvm dart test— 1798 passed, 4 skippedfvm flutter test— 1648 passedCo-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com