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() {
64
64
} ;
65
65
} , [ client , log ] ) ;
66
66
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
+
67
72
const handleSubmit = ( ) => {
68
- client . send ( [ { text : textInput } ] ) ;
73
+ // Only send if the input is valid
74
+ if ( isValidInput ( textInput ) ) {
75
+ client . send ( [ { text : textInput } ] ) ;
69
76
70
- setTextInput ( "" ) ;
71
- if ( inputRef . current ) {
72
- inputRef . current . innerText = "" ;
77
+ setTextInput ( "" ) ;
78
+ if ( inputRef . current ) {
79
+ inputRef . current . innerText = "" ;
80
+ }
73
81
}
74
82
} ;
75
83
@@ -135,7 +143,10 @@ export default function SidePanel() {
135
143
if ( e . key === "Enter" && ! e . shiftKey ) {
136
144
e . preventDefault ( ) ;
137
145
e . stopPropagation ( ) ;
138
- handleSubmit ( ) ;
146
+ // Only submit if input is valid
147
+ if ( isValidInput ( textInput ) ) {
148
+ handleSubmit ( ) ;
149
+ }
139
150
}
140
151
} }
141
152
onChange = { ( e ) => setTextInput ( e . target . value ) }
@@ -152,6 +163,7 @@ export default function SidePanel() {
152
163
< button
153
164
className = "send-button material-symbols-outlined filled"
154
165
onClick = { handleSubmit }
166
+ disabled = { ! isValidInput ( textInput ) || ! connected }
155
167
>
156
168
send
157
169
</ button >
Original file line number Diff line number Diff line change 166
166
& :hover {
167
167
color : var (--Neutral-60 );
168
168
}
169
+
170
+ & :disabled {
171
+ color : var (--Neutral-15 );
172
+ cursor : not-allowed ;
173
+ opacity : 0.6 ;
174
+ }
169
175
}
170
176
171
177
.input-area {
You can’t perform that action at this time.
0 commit comments