From 9201e0222efdefbcc5a953ba5241509d8be58ea5 Mon Sep 17 00:00:00 2001 From: Petyo Ivanov Date: Mon, 16 Oct 2023 15:46:28 +0300 Subject: [PATCH] fix: stop resetting nested forms Fixes #127 --- src/examples/link-dialog.tsx | 3 +++ src/plugins/frontmatter/FrontmatterEditor.tsx | 5 ++++- src/plugins/link-dialog/LinkDialog.tsx | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/examples/link-dialog.tsx b/src/examples/link-dialog.tsx index 219ab40d..86827ecc 100644 --- a/src/examples/link-dialog.tsx +++ b/src/examples/link-dialog.tsx @@ -60,6 +60,9 @@ export function EditorInAForm() { evt.preventDefault() alert('main form submitted') }} + onReset={() => { + console.log('reset') + }} > void handleSubmit(onSubmit)(e) e.stopPropagation() }} - onReset={() => setFrontmatterDialogOpen(false)} + onReset={(e) => { + e.stopPropagation() + setFrontmatterDialogOpen(false) + }} > diff --git a/src/plugins/link-dialog/LinkDialog.tsx b/src/plugins/link-dialog/LinkDialog.tsx index c2e84825..488864d2 100644 --- a/src/plugins/link-dialog/LinkDialog.tsx +++ b/src/plugins/link-dialog/LinkDialog.tsx @@ -54,7 +54,10 @@ export function LinkEditForm({ url, title, onSubmit, onCancel, linkAutocompleteS e.stopPropagation() e.preventDefault() }} - onReset={onCancel} + onReset={(e) => { + e.stopPropagation() + onCancel() + }} className={classNames(styles.multiFieldForm, styles.linkDialogEditForm)} >