chore: fix variable change ux error

This commit is contained in:
Joel 2025-08-25 15:36:40 +08:00
parent c1b7412465
commit 4f56acd432

View File

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