diff --git a/src/components/side-panel/SidePanel.tsx b/src/components/side-panel/SidePanel.tsx index 26aef5943..682b57a33 100644 --- a/src/components/side-panel/SidePanel.tsx +++ b/src/components/side-panel/SidePanel.tsx @@ -64,12 +64,18 @@ export default function SidePanel() { }; }, [client, log]); + const isValidInput = (input: string): boolean => { + return input.trim().length > 0; + }; + const handleSubmit = () => { - client.send([{ text: textInput }]); + if (isValidInput(textInput)) { + client.send([{ text: textInput }]); - setTextInput(""); - if (inputRef.current) { - inputRef.current.innerText = ""; + setTextInput(""); + if (inputRef.current) { + inputRef.current.innerText = ""; + } } }; @@ -135,7 +141,9 @@ export default function SidePanel() { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); e.stopPropagation(); - handleSubmit(); + if (isValidInput(textInput)) { + handleSubmit(); + } } }} onChange={(e) => setTextInput(e.target.value)} @@ -152,6 +160,7 @@ export default function SidePanel() { diff --git a/src/components/side-panel/side-panel.scss b/src/components/side-panel/side-panel.scss index 97d34cf3d..7c9f8bc8c 100644 --- a/src/components/side-panel/side-panel.scss +++ b/src/components/side-panel/side-panel.scss @@ -166,6 +166,12 @@ &:hover { color: var(--Neutral-60); } + + &:disabled { + color: var(--Neutral-15); + cursor: not-allowed; + opacity: 0.6; + } } .input-area {