Skip to content

Commit 079e514

Browse files
committed
Fix selecting a template that doesn't exist
Fixes codesandbox#3454
1 parent d29b367 commit 079e514

File tree

1 file changed

+9
-0
lines changed
  • packages/app/src/app/components/CreateNewSandbox/CreateSandbox/TemplateList

1 file changed

+9
-0
lines changed

packages/app/src/app/components/CreateNewSandbox/CreateSandbox/TemplateList/TemplateList.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ export const TemplateList = ({
287287

288288
const template = getTemplateByIndex(num - 1);
289289

290+
if (!template) {
291+
return;
292+
}
293+
290294
track('Template Modal - Open Sandbox', { source: 'num-keys' });
291295
openSandbox(template.sandbox);
292296
}
@@ -309,6 +313,11 @@ export const TemplateList = ({
309313
e.preventDefault();
310314
const currentTemplate = getTemplateByIndex(focusedTemplateIndex);
311315

316+
if (!currentTemplate) {
317+
// There are no sandboxes
318+
return;
319+
}
320+
312321
track('Template Modal - Open Sandbox', { source: 'enter' });
313322
openSandbox(currentTemplate.sandbox, isMac ? e.metaKey : e.ctrlKey);
314323
}

0 commit comments

Comments
 (0)