Changed the CodeEditorModal to trigger a change when closing. This will accommodate any state updates to the editor

This commit is contained in:
Dean 2024-08-23 10:15:46 +01:00
parent f44d09b344
commit b9c685b83b
3 changed files with 13 additions and 3 deletions

View File

@ -1065,7 +1065,12 @@
value={inputData[key]}
/>
{:else if value.customType === "code"}
<CodeEditorModal>
<CodeEditorModal
on:hide={() => {
// Push any pending changes when the window closes
onChange({ [key]: inputData[key] })
}}
>
<div class:js-editor={editingJs}>
<div
class:js-code={editingJs}
@ -1075,7 +1080,11 @@
value={inputData[key]}
on:blur={e => {
// need to pass without the value inside
onChange({ [key]: e.detail })
inputData[key] = e.detail
}}
on:insert={e => {
// Blur events only happen once after inserting a binding
// State will now update on insert
inputData[key] = e.detail
}}
completions={stepCompletions}

View File

@ -11,7 +11,7 @@
}
</script>
<Modal bind:this={modal}>
<Modal bind:this={modal} on:hide>
<ModalContent
size="XL"
title="Edit Code"

View File

@ -140,6 +140,7 @@
}
: undefined,
})
dispatch("insert", editor.state.doc.toString())
}
// Match decoration for HBS bindings