fix(onboarding): correctly show select placeholder when default value does not exist in the list

This commit is contained in:
Théo LAGACHE
2026-06-19 14:21:34 +02:00
parent 9d0a0f8529
commit 1bcf7e353e
@@ -27,10 +27,10 @@ export const StepDefaults = () => {
const existingDefaults = (state?.context.flowData.defaults ?? const existingDefaults = (state?.context.flowData.defaults ??
{}) as OnboardingDefaultsData; {}) as OnboardingDefaultsData;
const [notifierId, setNotifierId] = useState<string | undefined>( const [notifierId, setNotifierId] = useState<string | undefined>(
existingDefaults.notifierId, existingDefaults.notifierId || undefined,
); );
const [storageId, setStorageId] = useState<string | undefined>( const [storageId, setStorageId] = useState<string | undefined>(
existingDefaults.storageId, existingDefaults.storageId || undefined,
); );
@@ -83,7 +83,7 @@ export const StepDefaults = () => {
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<Label>Default notifier</Label> <Label>Default notifier</Label>
<Select <Select
value={notifierId} value={notifiers.some((n) => n.id === notifierId) ? notifierId : undefined}
onValueChange={selectNotifier} onValueChange={selectNotifier}
disabled={notifiers.length === 0} disabled={notifiers.length === 0}
> >
@@ -108,7 +108,7 @@ export const StepDefaults = () => {
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<Label>Default storage</Label> <Label>Default storage</Label>
<Select <Select
value={storageId} value={storages.some((s) => s.id === storageId) ? storageId : undefined}
onValueChange={selectStorage} onValueChange={selectStorage}
disabled={storages.length === 0} disabled={storages.length === 0}
> >