Skip to content

Commit 9169ce1

Browse files
updated event delegation in the delete project
1 parent 0b87038 commit 9169ce1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/routes/(console)/project-[region]-[project]/settings/deleteProject.svelte

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import { project, projectRegion } from '../store';
1212
import { organization } from '$lib/stores/organization';
1313
import { Dependencies } from '$lib/constants';
14+
import { onDestroy, onMount } from 'svelte';
1415
1516
let error: string;
1617
let showDelete = false;
@@ -39,6 +40,21 @@
3940
trackError(e, Submit.ProjectDelete);
4041
}
4142
};
43+
44+
const handleKeydown = (e: KeyboardEvent) => {
45+
if (e.key === 'Enter') {
46+
if (name !== $project.name) e.preventDefault();
47+
else handleDelete();
48+
}
49+
};
50+
51+
onMount(() => {
52+
window.addEventListener('keydown', handleKeydown);
53+
});
54+
55+
onDestroy(() => {
56+
window.removeEventListener('keydown', handleKeydown);
57+
});
4258
</script>
4359

4460
<CardGrid>

0 commit comments

Comments
 (0)