feat(createCombobox): commit free-text values in non-strict mode#383
Draft
johnleider wants to merge 3 commits into
Draft
feat(createCombobox): commit free-text values in non-strict mode#383johnleider wants to merge 3 commits into
johnleider wants to merge 3 commits into
Conversation
A non-strict combobox (the default) now accepts typed text that matches no registered option. Confirming with Enter or Tab mints a ticket for the typed value, selects it, and emits it through v-model; strict keeps the constrained behaviour and discards unmatched text on confirm. Adds a commit() action to the combobox context, wired to Enter (no highlight) and Tab in ComboboxControl. Free-text values are kept out of keyboard navigation and pruned when superseded (single-select) or cleared. Corrects the strict prop and docs, which previously described the unconditional revert-on-close as if it were strict-gated.
|
commit: |
Tab routes to commit()/select(), neither of which closes the menu in multiple-select mode, and useClickOutside only dismisses on pointer events — so tabbing out left the listbox floating over the next focused control. Close explicitly on Tab (idempotent for single-select, which already closes via commit/select).
# Conflicts: # apps/docs/src/pages/components/forms/combobox.md
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.
Summary
createComboboxexposed astrictoption whose only real effect was thearia-autocompleteattribute. The documented "reverts query to selected value on close" behaviour was unconditional (driven bypristine+display, fired on everyclose()), sostrictwas effectively cosmetic — and the default non-strict combobox silently discarded any typed text that didn't match a registered option. A non-strict / free-solo combobox is supposed to accept arbitrary values.This PR makes non-strict mean what it says: typed text that matches no option is committed as a value.
What changed
commit()action on the combobox context. On confirm it selects an exact value match if one exists; otherwise, when!strict, it mints a registry ticket for the typed text, selects it, and emits it throughv-model. Whenstrict, unmatched text is discarded.ComboboxControlwirescommit()to Enter (when nothing is highlighted) and Tab (accept highlight, else commit). Escape still cancels/reverts — which is why commit lives in its own action rather than inclose()(Escape and click-outside both route throughclose()).clear().strictprop, module remarks, Strict Mode prose, thearia-autocompletenote, and the keyboard table previously described the unconditional revert as if it were strict-gated.Design note
This is the "register-on-commit" approach (vs. a parallel free-value channel) — it composes with the existing ticket/
useProxyModelmachinery instead of bolting a second value path onto every selection consumer. Single-select is the primary path; multiple-select (free-text tags) works but is the lighter-tested surface — removing a tag via direct deselect leaves an orphaned-but-deselected ticket untilclear().Tests
No automated tests are included in this commit, per the repo convention of not adding tests unless requested. The existing 119 combobox tests pass unchanged (the new behaviour is keyed on Enter/Tab; the prior "strict mode" tests exercise
close()and are unaffected). Thecommit()path — free-text emit, strict discard, exact-match dedup, single-select pruning — is currently uncovered; happy to add a focuseddescribe('free-text commit')block if you want it in this PR.