ENG-3832: Render multi-select dropdown for taxonomy[] custom fields#8197
ENG-3832: Render multi-select dropdown for taxonomy[] custom fields#8197wadesdev wants to merge 27 commits into
Conversation
…] suffix Update hooks.ts to treat any field_type ending in "[]" as a multi-value array (not just "string[]"), so taxonomy-backed multi-select values are preserved. Update TaxonomyCustomFieldsForm to strip the [] suffix and pass mode="multiple" to CustomTaxonomySelect when the definition uses a "taxonomy[]" field type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…#8197) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
…itions Show a "Selection mode" dropdown (single/multiple) in CustomFieldForm when a taxonomy template is selected. Submitting with "multiple" appends "[]" to the field_type sent to the backend. Editing an existing "[]" definition pre-populates the selection mode correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…omField Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…fields table Fixes the Type column showing lowercase "geo[]" for multi-select taxonomy fields — strip the [] suffix before looking up the taxonomy name so it resolves to the taxonomy's display name (e.g. "Geo") instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/code-review |
There was a problem hiding this comment.
Code Review – ENG-3832: Multi-select taxonomy custom fields
The overall approach is well-structured: the []-suffix convention is applied consistently across hooks, table rendering, form initialisation, payload construction, and the taxonomy detail form. The CustomTaxonomySelect interface already constrains mode to "multiple" | undefined, so the pass-through is clean.
Bug (needs fix before merge)
CustomFieldForm.tsx — Form.Item initialValue overrides Form initialValues on edit.
The selection_mode Form.Item has initialValue="single". In Ant Design, Form.Item-level initialValue takes precedence over the Form's initialValues. This means when editing an existing "risk[]" field, parseFieldToFormValues correctly sets selection_mode: "multiple" in Form initialValues, but the Form.Item resets it to "single" on mount. The edit flow would always show "Single select" as the pre-selected value. The fix is to drop the initialValue from the Form.Item — parseFieldToFormValues and the onChange handler already cover all initialisation paths.
Minor issues
-
useCustomFieldsTable.tsx—[]suffix leaks throughgetCustomFieldTypeLabelfallback. If the taxonomy lookup returns nothing (taxonomy deleted, not yet loaded),getCustomFieldTypeLabelis called with the originalrecordstill carryingfield_type: "risk[]".getCustomFieldTypedoesn't strip[], so the rendered cell label is the raw"risk[]"string. Passing{ ...record, field_type: baseFieldType }to the fallback avoids this. -
hooks.ts— implicit behavioural change forstring[]withoutallow_list_id. The old guard requiredallow_list_idto be set before treatingstring[]as an array. The newendsWith("[]")check removes that gate. In practice this is correct, but a short comment explaining the intentional broadening would help future readers. -
TaxonomyCustomFieldsForm.tsx— redundantdefaultValueonCustomTaxonomySelect. This is pre-existing, but with the new multi-select path it becomes more relevant: in a controlled Ant Design Form,defaultValueon a child input is shadowed by the Form field value injected viaForm.Item name. The value is already inForm initialValues; thedefaultValueprop is a no-op at best and confusing at worst.
What's good
[]-suffix stripping is applied in every affected callsite — no missed spots spotted.useCreateOrUpdateCustomFieldcorrectly appends/strips[]at the persistence boundary, keeping the convention contained.- The
selection_modefield is correctly excluded from the API payload via destructuring. CustomTaxonomySelectinterface already restrictsmodeto"multiple"— no risk of passing unsupported Ant Design modes.
🔬 Codegraph: connected (50522 nodes)
💡 Write /code-review in a comment to re-run this review.
| taxonomyKey={fieldType} | ||
| taxonomyKey={taxonomyKey} | ||
| mode={isMultiSelectTaxonomy ? "multiple" : undefined} | ||
| defaultValue={customFields.customFieldValues[id]} |
There was a problem hiding this comment.
clients/admin-ui/src/features/taxonomy/components/TaxonomyCustomFieldsForm.tsx:80
defaultValue is pre-existing here, but it's worth flagging with the new multi-select path: in a controlled Ant Design Form, defaultValue on an inner component is generally ignored in favour of the Form's field value (set via name={id} on the parent Form.Item). The value from customFields.customFieldValues should already be injected through Form initialValues on the wrapping <Form> at line 35. Passing it again as defaultValue is redundant and won't cause a bug here, but it can be confusing and mask issues if the form re-initialises. Consider removing defaultValue and relying solely on the Form's controlled state.
…changes
- Remove initialValue="single" from Form.Item to fix edit form always
showing "Single select" for existing multi-select definitions
- Pass stripped baseFieldType to getCustomFieldTypeLabel fallback so
deleted/unloaded taxonomies don't show raw "geo[]" in the type column
- Add comment on endsWith("[]") condition in hooks.ts clarifying it
intentionally covers both legacy string[] and new taxonomy[] cases
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add required validation rule to selection_mode Form.Item - Default selection_mode to "single" in Form initialValues for new fields - Strip selection_mode from OPEN_TEXT and SELECT payloads so it is not sent to the backend on non-taxonomy field types Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gilluminate
left a comment
There was a problem hiding this comment.
Approving with the caveat that the lint errors still need to be addressed.
| <Form.Item | ||
| label="Selection mode" | ||
| name="selection_mode" | ||
| rules={[{ required: true, message: "Please select a selection mode" }]} |
There was a problem hiding this comment.
@wadesdev run npm run check to clean up these lint warnings
|
DatamapReportTableColumns.tsx:129 — |
Ticket ENG-3832
Description Of Changes
Frontend companion to the fidesplus backend PR for ENG-3832. Custom taxonomy-backed custom fields now support multi-select when their
field_typeends in[](e.g."risk[]"). The taxonomy detail page renders a multi-select dropdown for these fields and correctly preserves array values through the form.Code Changes
clients/admin-ui/src/features/common/custom-fields/hooks.ts— update array detection incustomFieldValuesmemo: previously only treated"string[]"with an allow list as arrays; now anyfield_typeending in[]is preserved as an array (covers taxonomy multi-select)clients/admin-ui/src/features/taxonomy/components/TaxonomyCustomFieldsForm.tsx— detect[]suffix onfieldType, strip it for thetaxonomyKeyprop passed toCustomTaxonomySelect, and passmode="multiple"when the field is multi-selectSteps to Confirm
npm run devinclients/admin-ui/, backend running)field_type: "risk[]"via the API"risk"field (no[]) still renders as a single-select dropdownPre-Merge Checklist
CHANGELOG.mdupdatedtaxonomies-plus.cy.ts)