mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 17:13:42 +00:00
fix: use sentinel value for empty Radix Select option to prevent crash
Radix UI Select.Item does not allow empty string values. The Anrede dropdown used value="" for the empty option, causing the entire React app to crash when entering edit mode. Use '__none__' sentinel value instead and convert to null on selection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
19db4c5def
commit
7e9373a6d0
2 changed files with 5 additions and 4 deletions
|
|
@ -33,7 +33,8 @@ function formatDisplayValue(field: FieldConfig, value: unknown): string {
|
|||
if (field.type === 'date') return formatDisplayDate(value as string | null)
|
||||
if (field.type === 'boolean') return formatDisplayBoolean(value)
|
||||
if (field.type === 'select' && field.options) {
|
||||
const opt = field.options.find((o) => o.value === (value ?? ''))
|
||||
const matchVal = value || '__none__'
|
||||
const opt = field.options.find((o) => o.value === matchVal)
|
||||
return opt?.label || (value as string) || '–'
|
||||
}
|
||||
return (value as string) || '–'
|
||||
|
|
@ -93,8 +94,8 @@ export function EditableField({ field, value, editable, onChange }: EditableFiel
|
|||
)}
|
||||
{field.type === 'select' && field.options && (
|
||||
<Select
|
||||
value={(value as string) ?? ''}
|
||||
onValueChange={(v) => handleChange(v || null)}
|
||||
value={(value as string) || '__none__'}
|
||||
onValueChange={(v) => handleChange(v === '__none__' ? null : v)}
|
||||
>
|
||||
<SelectTrigger className="h-8 text-sm">
|
||||
<SelectValue placeholder="Auswählen..." />
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export interface SectionConfig {
|
|||
}
|
||||
|
||||
const ANREDE_OPTIONS = [
|
||||
{ value: '', label: '–' },
|
||||
{ value: '__none__', label: '–' },
|
||||
{ value: 'Herr', label: 'Herr' },
|
||||
{ value: 'Frau', label: 'Frau' },
|
||||
{ value: 'Divers', label: 'Divers' },
|
||||
|
|
|
|||
Loading…
Reference in a new issue