Add 'allowCustomValue' flag to string field combobox - #115
Merged
joshunrau merged 2 commits intoAug 11, 2026
Merged
Conversation
joshunrau
approved these changes
Aug 11, 2026
|
🎉 This PR is included in version 6.14.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
Exposes the ComboBox
allowCustomValueflag through the form'scomboboxstring field variant, so a form field can accept text that doesn't match any of itsoptions.Changes
StringFieldComboBoxallowCustomValue?: booleanprop (defaults tofalse, preserving current behaviour).{ label, value }objects, andComboboxRoot's boolean path commits the raw typed string as the value — which would makeonValueChange'sitem?.valuecome backundefined. It now passes(inputValue) => ({ label: inputValue, value: inputValue }).selected. A custom value is by definition absent fromitems, soitems.find(...) ?? nullresolved tonull; because the ComboBox is controlled, the input blanked out the instant a custom value was committed. It now falls back to an item built from the value itself when the flag is on.StringField.stories.tsxallowCustomValueis now toggleable from the controls panel, with an explicitargTypesentry (docgen inference on the union-typedStringFielddoesn't reliably produce the boolean control).allowCustomValuefrom its story context. Args passed to<Story args={...} />inside a decorator override story-level args, so a hardcoded value there would render the control but make it inert.StoryObj<StringFieldComboBoxProps>. Readingargs.allowCustomValueoffStoryObj<typeof StringField>doesn't typecheck, since those args are the fullStringFieldPropsunion and the input/textarea/password members have no such property. Runtime is unchanged — the meta still rendersStringField, which dispatches onvariant.Notes for reviewers
StringFormFieldfrom@douglasneuroinformatics/libui-form-types, wherecomboboxshares a union member withradioandselect. A form config object literal carryingallowCustomValuewill fail excess-property checking until that package splits the combobox variant out and adds the prop. For now the flag only reaches the component whenStringFieldComboBoxis rendered directly (as the Storybook story does). Upstream change to follow.options, so any validation schema for the field has to accept arbitrary strings rather than a fixed enum. This is documented in the prop's JSDoc.Testing
tsc --noEmitandeslintclean.ComboBoxandFormsuites pass (30 tests).selectedfallback in particular is worth covering — it's the kind of thing a future refactor could quietly undo — so a spec that types a custom value and asserts the input retains it after re-render would be a good follow-up.