Skip to content

Commit 34a07f0

Browse files
authored
[dashboard] QoL improvement: Ctrl+Enter (#19800)
1 parent e367ae7 commit 34a07f0

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

components/dashboard/src/workspaces/CreateWorkspacePage.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ import { isGitpodIo } from "../utils";
5858

5959
type NextLoadOption = "searchParams" | "autoStart" | "allDone";
6060

61+
export const StartWorkspaceKeyBinding = `${/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform) ? "⌘" : "Ctrl﹢"}Enter`;
62+
6163
export function CreateWorkspacePage() {
6264
const { user, setUser } = useContext(UserContext);
6365
const updateUser = useUpdateCurrentUserMutation();
@@ -429,6 +431,21 @@ export function CreateWorkspacePage() {
429431
return false;
430432
}, [autostart, contextURL, errorIde, errorWsClass, workspaceContext.error, workspaceContext.isLoading]);
431433

434+
useEffect(() => {
435+
const onKeyDown = (event: KeyboardEvent) => {
436+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
437+
if (!continueButtonDisabled) {
438+
event.preventDefault();
439+
onClickCreate();
440+
}
441+
}
442+
};
443+
window.addEventListener("keydown", onKeyDown);
444+
return () => {
445+
window.removeEventListener("keydown", onKeyDown);
446+
};
447+
}, [continueButtonDisabled, onClickCreate]);
448+
432449
if (SelectAccountPayload.is(selectAccountError)) {
433450
return (
434451
<SelectAccountModal
@@ -546,7 +563,9 @@ export function CreateWorkspacePage() {
546563
loading={createWorkspaceMutation.isStarting || !!autostart}
547564
disabled={continueButtonDisabled}
548565
>
549-
{createWorkspaceMutation.isStarting ? "Opening Workspace ..." : "Continue"}
566+
{createWorkspaceMutation.isStarting
567+
? "Opening Workspace ..."
568+
: `Continue (${StartWorkspaceKeyBinding})`}
550569
</LoadingButton>
551570
</div>
552571
{existingWorkspaces.length > 0 && !createWorkspaceMutation.isStarting && (

0 commit comments

Comments
 (0)