fix: Enter on dropdown executes command immediately

Previously selecting a slash command with Enter just filled the
input, requiring a second Enter to send. Now Enter directly
executes the command transform (or opens /poll modal) and sends.
This commit is contained in:
2026-07-02 12:47:58 -04:00
parent cf2f1c96a3
commit aa80e354c9
+15 -2
View File
@@ -783,10 +783,23 @@ export function ChatArea() {
const q = commandQuery.toLowerCase(); const q = commandQuery.toLowerCase();
const filtered = SLASH_COMMANDS.filter((c) => c.name.startsWith(q)).slice(0, 8); const filtered = SLASH_COMMANDS.filter((c) => c.name.startsWith(q)).slice(0, 8);
if (filtered[dropdownIndex]) { if (filtered[dropdownIndex]) {
setInput('/' + filtered[dropdownIndex].name + ' '); const cmd = filtered[dropdownIndex];
setCommandQuery(null); setCommandQuery(null);
setDropdownIndex(0); setDropdownIndex(0);
inputRef.current?.focus(); // /poll opens modal instead of sending a message
if (cmd.name === 'poll') {
setShowPollModal(true);
setInput('');
return;
}
// ponytail: execute the command transform directly
const args = input.startsWith('/' + cmd.name + ' ')
? input.slice(cmd.name.length + 2).trim()
: '';
const text = cmd.transform(args, currentUser?.username || 'user');
sendMessage(activeChannelId!, text, replyToMessage?.id);
setInput('');
setReplyToMessage(null);
} }
} }
} else if (e.key === 'Escape') { } else if (e.key === 'Escape') {