Skip to content

Commit

Permalink
Small CodeBlock in Modal fixes (#2225)
Browse files Browse the repository at this point in the history
* Make sure handleCancel is only called once by only triggering dialog close once

* Destroy codeblock editor view on unmount
  • Loading branch information
laurakwhit authored Jul 22, 2024
1 parent 50a5e10 commit 88eeac1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/lib/holocene/code-block.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
onMount(() => {
view = createEditorView();
return () => view.destroy();
});
export const resetView = (value = '', format = true) => {
Expand Down
10 changes: 7 additions & 3 deletions src/lib/holocene/modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@
dispatch('confirmModal');
};
const closeModal = () => {
open = false;
};
const handleClick = (event: MouseEvent) => {
if (event.target === modalElement) handleCancel();
if (event.target === modalElement) closeModal();
};
$: {
Expand Down Expand Up @@ -97,7 +101,7 @@
label={cancelText}
icon="close"
class="float-right m-4"
on:click={handleCancel}
on:click={closeModal}
/>
{/if}
<div id="modal-title-{id}" class="title">
Expand All @@ -115,7 +119,7 @@
</p>
</div>
<div class="flex items-center justify-end space-x-2 p-6">
<Button variant="ghost" disabled={loading} on:click={handleCancel}
<Button variant="ghost" disabled={loading} on:click={closeModal}
>{cancelText}</Button
>
{#if !hideConfirm}
Expand Down

0 comments on commit 88eeac1

Please sign in to comment.