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:
@@ -783,10 +783,23 @@ export function ChatArea() {
|
||||
const q = commandQuery.toLowerCase();
|
||||
const filtered = SLASH_COMMANDS.filter((c) => c.name.startsWith(q)).slice(0, 8);
|
||||
if (filtered[dropdownIndex]) {
|
||||
setInput('/' + filtered[dropdownIndex].name + ' ');
|
||||
const cmd = filtered[dropdownIndex];
|
||||
setCommandQuery(null);
|
||||
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') {
|
||||
|
||||
Reference in New Issue
Block a user