fix(custom-fields): tri-state bool input, case-insensitive bool default coerce, multi_select default uses | separator#40
Merged
Conversation
…lt coerce, multi_select default uses | separator
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
Three custom-field UX bugs from the same surface, fixed together so the form/admin pair stays consistent.
FieldControlrendered a<input type=checkbox>for bool fields, sovalue=falseand "user hasn't touched it yet" looked identical and there was no way to express "use the field's default". Replaced with a tri-state<Select>that always exposes three options:truefalseundefinedso the backend'sdefault_valuewins. The label folds in the declared default when one is set, so admins immediately see what "Not set" actually means in this project.coerceDefaultwas case-sensitive. The dialog only accepted literal"true"/"1";"True"/"TRUE"/"yes"silently savedfalse. The new helper lowercases + trims and acceptstrue|1|yes|y|on|sí|si|sas true,false|0|no|n|offas false, anything else as false."web, mobile"), so the oldraw.split(",")produced bogus values. Switched the default-value separator to|(already the convention used in the options input), updated the placeholder + hint per type, and the helper nowString(raw).split("|").trim().filter(Boolean).Refactor:
coerceDefaultfromCustomFieldsPanel.jsxintofrontend/src/lib/customFieldDefaults.jsso the rules are unit-testable in isolation.CustomFieldsPanel.jsxjust imports it.Tests:
customFieldDefaults.test.jscovers bool true/false case variants, multi_select pipe split with commas inside values, whitespace trimming, plus the number/text passthrough.CustomFieldInput.test.jsxupdated: dropped the obsolete checkbox test, added three new cases — pick Yes emitstrue, pick No emitsfalse(distinct from unset), and the unset option label surfaces the declared default ("Default (No)").