File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
src/components/side-panel Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -64,12 +64,20 @@ export default function SidePanel() {
6464 } ;
6565 } , [ client , log ] ) ;
6666
67+ // Helper function to check if input is valid (not empty and not just whitespace)
68+ const isValidInput = ( input : string ) : boolean => {
69+ return input . trim ( ) . length > 0 ;
70+ } ;
71+
6772 const handleSubmit = ( ) => {
68- client . send ( [ { text : textInput } ] ) ;
73+ // Only send if the input is valid
74+ if ( isValidInput ( textInput ) ) {
75+ client . send ( [ { text : textInput } ] ) ;
6976
70- setTextInput ( "" ) ;
71- if ( inputRef . current ) {
72- inputRef . current . innerText = "" ;
77+ setTextInput ( "" ) ;
78+ if ( inputRef . current ) {
79+ inputRef . current . innerText = "" ;
80+ }
7381 }
7482 } ;
7583
@@ -135,7 +143,10 @@ export default function SidePanel() {
135143 if ( e . key === "Enter" && ! e . shiftKey ) {
136144 e . preventDefault ( ) ;
137145 e . stopPropagation ( ) ;
138- handleSubmit ( ) ;
146+ // Only submit if input is valid
147+ if ( isValidInput ( textInput ) ) {
148+ handleSubmit ( ) ;
149+ }
139150 }
140151 } }
141152 onChange = { ( e ) => setTextInput ( e . target . value ) }
@@ -152,6 +163,7 @@ export default function SidePanel() {
152163 < button
153164 className = "send-button material-symbols-outlined filled"
154165 onClick = { handleSubmit }
166+ disabled = { ! isValidInput ( textInput ) || ! connected }
155167 >
156168 send
157169 </ button >
Original file line number Diff line number Diff line change 166166 & :hover {
167167 color : var (--Neutral-60 );
168168 }
169+
170+ & :disabled {
171+ color : var (--Neutral-15 );
172+ cursor : not-allowed ;
173+ opacity : 0.6 ;
174+ }
169175 }
170176
171177 .input-area {
You can’t perform that action at this time.
0 commit comments