chore: fix variable change ux error

This commit is contained in:
Joel 2025-08-25 15:36:40 +08:00
parent c1b7412465
commit 4f56acd432
1 changed files with 4 additions and 4 deletions

View File

@ -53,7 +53,7 @@ const PrePopulate: FC<Props> = ({
onValueChange,
}) => {
const [onPlaceholderClicked, setOnPlaceholderClicked] = useState(false)
const handlePlaceholderTypeClick = useCallback((isVar: boolean) => {
const handleTypeChange = useCallback((isVar: boolean) => {
setOnPlaceholderClicked(true)
onIsVariableChange?.(isVar)
}, [onIsVariableChange])
@ -62,7 +62,7 @@ const PrePopulate: FC<Props> = ({
const isShowPlaceholder = !onPlaceholderClicked && (isVariable ? (!valueSelector || valueSelector.length === 0) : !value)
if (isShowPlaceholder)
return <Placeholder onTypeClick={handlePlaceholderTypeClick} />
return <Placeholder onTypeClick={handleTypeChange} />
if (isVariable) {
return (
@ -74,7 +74,7 @@ const PrePopulate: FC<Props> = ({
readonly={false}
zIndex={1000}
/>
<TypeSwitch isVariable={isVariable} onIsVariableChange={onIsVariableChange} />
<TypeSwitch isVariable={isVariable} onIsVariableChange={handleTypeChange} />
</div>
)
}
@ -90,7 +90,7 @@ const PrePopulate: FC<Props> = ({
<TypeSwitch
className='ml-1.5'
isVariable={isVariable}
onIsVariableChange={onIsVariableChange}
onIsVariableChange={handleTypeChange}
/>
</div>
)