Skip to content

fix(custom-fields): tri-state bool input, case-insensitive bool default coerce, multi_select default uses | separator#40

Merged
jamofer merged 2 commits into
masterfrom
fix/custom-fields-input-polish
May 24, 2026
Merged

fix(custom-fields): tri-state bool input, case-insensitive bool default coerce, multi_select default uses | separator#40
jamofer merged 2 commits into
masterfrom
fix/custom-fields-input-polish

Conversation

@jamofer

@jamofer jamofer commented May 24, 2026

Copy link
Copy Markdown
Owner

Summary

Three custom-field UX bugs from the same surface, fixed together so the form/admin pair stays consistent.

  • Bool input was indistinguishable from default. FieldControl rendered a <input type=checkbox> for bool fields, so value=false and "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:
    • Yes → emits true
    • No → emits false
    • Not set / Default (Yes|No) → emits undefined so the backend's default_value wins. The label folds in the declared default when one is set, so admins immediately see what "Not set" actually means in this project.
  • Bool coerceDefault was case-sensitive. The dialog only accepted literal "true" / "1"; "True" / "TRUE" / "yes" silently saved false. The new helper lowercases + trims and accepts true|1|yes|y|on|sí|si|s as true, false|0|no|n|off as false, anything else as false.
  • multi_select default split on commas. Option values are allowed to contain commas (e.g. "web, mobile"), so the old raw.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 now String(raw).split("|").trim().filter(Boolean).

Refactor:

  • Extracted coerceDefault from CustomFieldsPanel.jsx into frontend/src/lib/customFieldDefaults.js so the rules are unit-testable in isolation. CustomFieldsPanel.jsx just imports it.
  • New per-type default placeholder + hint helper avoids the generic message lying about acceptable input.

Tests:

  • customFieldDefaults.test.js covers bool true/false case variants, multi_select pipe split with commas inside values, whitespace trimming, plus the number/text passthrough.
  • CustomFieldInput.test.jsx updated: dropped the obsolete checkbox test, added three new cases — pick Yes emits true, pick No emits false (distinct from unset), and the unset option label surfaces the declared default ("Default (No)").

@jamofer jamofer merged commit e2702da into master May 24, 2026
5 checks passed
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.

1 participant