mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(site): add cmd+enter to submit tasks immediately (#21182)
Implements cmd+enter (Mac) / ctrl+enter (Windows/Linux) keyboard shortcut for submitting tasks on the tasks page. Regular enter key still creates new lines as expected. Fixes #21179 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.5
parent
ed3bb76c9b
commit
8e460ca865
@@ -216,7 +216,7 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
const onSubmit = async (e: React.SyntheticEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
@@ -231,6 +231,13 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
// Submit form on Cmd+Enter (Mac) or Ctrl+Enter (Windows/Linux)
|
||||
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
||||
onSubmit(e);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={onSubmit}
|
||||
@@ -259,6 +266,7 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
|
||||
onChange={(e) => setPrompt(e.target.value)}
|
||||
readOnly={isPromptReadOnly}
|
||||
isSubmitting={createTaskMutation.isPending}
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
<div className="flex items-center justify-between pt-2">
|
||||
<div className="flex items-center gap-1">
|
||||
|
||||
Reference in New Issue
Block a user