diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx index a333cd9..a715131 100644 --- a/components/InspectorOperations.tsx +++ b/components/InspectorOperations.tsx @@ -54,7 +54,7 @@ export default function InspectorOperations({ }) { const [file, setFile] = useState([]); const [check, setCheck] = useState(false); - const [charCount, setCharCount] = useState(0); + const [charCount, setCharCount] = useState(0); // Queries const { data, isLoading, refetch } = useQuery({ @@ -132,18 +132,22 @@ export default function InspectorOperations({ }, }); - // Add the useEffect hook to monitor changes in the description field - useEffect(() => { - setCharCount(form.watch("text")?.length); - }, [form.watch("text")]); - - function handleTextChange(event: React.ChangeEvent) { - const newCharCount = event.target.value.length; - // Update charCount only when the user types or removes characters - if (newCharCount <= data?.maxTextLength) { - setCharCount(newCharCount); - } + // Add the useEffect hook to monitor changes in the description field + useEffect(() => { + const text = form.watch("text") as string; + if (charCount != 0) { + setCharCount(text?.length); + console.log(charCount); } + }, [form.watch("text")]); + + function handleTextChange(event: React.ChangeEvent) { + const newCharCount = event.target.value.length; + // Update charCount only when the user types or removes characters + if (newCharCount <= data?.maxTextLength) { + setCharCount(newCharCount); + } + } function onSubmit(data: z.infer) { const storedData = JSON.parse( diff --git a/package-lock.json b/package-lock.json index cd974e5..6ab8021 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sootzani", - "version": "0.2.21", + "version": "0.2.22", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sootzani", - "version": "0.2.21", + "version": "0.2.22", "dependencies": { "@hookform/resolvers": "^3.3.2", "@microsoft/signalr": "^8.0.0", diff --git a/package.json b/package.json index e5e716e..ecdccd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sootzani", - "version": "0.2.21", + "version": "0.2.22", "private": true, "scripts": { "dev": "next dev",