Fix duplicate None/null options (#1384)

fmt
This commit is contained in:
Alex Netsch
2025-11-27 18:15:46 +00:00
committed by GitHub
parent c06c3a90f5
commit 34236c9572

View File

@@ -41,10 +41,14 @@ export const SelectWidget = (props: WidgetProps) => {
// Convert enumOptions to the format expected by our Select component // Convert enumOptions to the format expected by our Select component
const selectOptions = enumOptions || []; const selectOptions = enumOptions || [];
// Handle nullable types by adding a null option // Handle nullable types by adding a null option and filtering out null from enumOptions
// (schema has null in both type and enum, but String(null) breaks validation)
const isNullable = Array.isArray(schema.type) && schema.type.includes('null'); const isNullable = Array.isArray(schema.type) && schema.type.includes('null');
const allOptions = isNullable const allOptions = isNullable
? [{ value: '__null__', label: 'None' }, ...selectOptions] ? [
{ value: '__null__', label: 'Not specified' },
...selectOptions.filter((opt) => opt.value !== null),
]
: selectOptions; : selectOptions;
return ( return (