From 794db8f10b8f452c0b72a901e2dde4870c041865 Mon Sep 17 00:00:00 2001 From: Federico Ruggi <1081051+ruggi@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:53:11 +0200 Subject: [PATCH] tweak --- editor/src/components/inspector/flex-section.tsx | 2 +- editor/src/uuiui/radix-components.tsx | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/editor/src/components/inspector/flex-section.tsx b/editor/src/components/inspector/flex-section.tsx index 6d019d643517..8afca94bc45f 100644 --- a/editor/src/components/inspector/flex-section.tsx +++ b/editor/src/components/inspector/flex-section.tsx @@ -967,7 +967,7 @@ function selectOption(value: GridAutoFlow) { } const unsetSelectOption = regularRadixSelectOption({ - label: (isOpen) => (isOpen ? 'unset' : 'auto'), + label: (isOpen, currentValue) => (isOpen && currentValue !== 'auto' ? 'unset' : 'auto'), value: 'auto', placeholder: true, }) diff --git a/editor/src/uuiui/radix-components.tsx b/editor/src/uuiui/radix-components.tsx index d0c36e2d009d..86ed787124af 100644 --- a/editor/src/uuiui/radix-components.tsx +++ b/editor/src/uuiui/radix-components.tsx @@ -228,7 +228,7 @@ Separator.displayName = 'Separator' type RegularRadixSelectOption = { type: 'REGULAR' value: string - label: string | ((isOpen: boolean) => string) + label: string | ((isOpen: boolean, currentValue: string | null) => string) icon?: IcnProps placeholder?: boolean } @@ -257,12 +257,13 @@ export type RadixSelectOption = RegularRadixSelectOption | Separator function optionLabelToString( option: RegularRadixSelectOption | null, isOpen: boolean, + currentValue: string | null, ): string | null { if (option == null) { return null } - const label = typeof option.label === 'string' ? option.label : option.label(isOpen) + const label = typeof option.label === 'string' ? option.label : option.label(isOpen, currentValue) return `${label.charAt(0).toUpperCase()}${label.slice(1)}` } @@ -293,7 +294,7 @@ export const RadixSelect = React.memo( [propsOnOpenChange], ) - const valueLabel = optionLabelToString(props.value ?? null, isOpen) + const valueLabel = optionLabelToString(props.value ?? null, isOpen, props.value?.value ?? null) return (