Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ruggi committed Oct 9, 2024
1 parent f18cfe9 commit 794db8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion editor/src/components/inspector/flex-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
9 changes: 5 additions & 4 deletions editor/src/uuiui/radix-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)}`
}
Expand Down Expand Up @@ -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 (
<Select.Root
Expand Down Expand Up @@ -365,7 +366,7 @@ export const RadixSelect = React.memo(
)
}

const label = optionLabelToString(option, isOpen)
const label = optionLabelToString(option, isOpen, props.value?.value ?? null)
return (
<Select.Item
key={`select-option-${props.id}-${index}`}
Expand Down

0 comments on commit 794db8f

Please sign in to comment.