feat(engine): ✨ Link typebot step
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { Textarea, TextareaProps } from '@chakra-ui/react'
|
||||
import { ChangeEvent, useEffect, useState } from 'react'
|
||||
import { useDebounce } from 'use-debounce'
|
||||
|
||||
type Props = Omit<TextareaProps, 'onChange' | 'value'> & {
|
||||
initialValue: string
|
||||
@ -12,12 +13,16 @@ export const DebouncedTextarea = ({
|
||||
...props
|
||||
}: Props) => {
|
||||
const [currentValue, setCurrentValue] = useState(initialValue)
|
||||
const [debouncedValue] = useDebounce(
|
||||
currentValue,
|
||||
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : 1000
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (currentValue === initialValue) return
|
||||
onChange(currentValue)
|
||||
if (debouncedValue === initialValue) return
|
||||
onChange(debouncedValue)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentValue])
|
||||
}, [debouncedValue])
|
||||
|
||||
const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
setCurrentValue(e.target.value)
|
||||
|
Reference in New Issue
Block a user