Skip to content

Commit

Permalink
fix: stop resetting nested forms
Browse files Browse the repository at this point in the history
Fixes #127
  • Loading branch information
petyosi committed Oct 16, 2023
1 parent 7b11c86 commit 9201e02
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/examples/link-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export function EditorInAForm() {
evt.preventDefault()
alert('main form submitted')
}}
onReset={() => {
console.log('reset')
}}
>
<MDXEditor
markdown="[Link](http://www.example.com)"
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/frontmatter/FrontmatterEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export const FrontmatterEditor = ({ yaml, onChange }: FrontmatterEditorProps) =>
void handleSubmit(onSubmit)(e)
e.stopPropagation()
}}
onReset={() => setFrontmatterDialogOpen(false)}
onReset={(e) => {
e.stopPropagation()
setFrontmatterDialogOpen(false)
}}
>
<table className={styles.propertyEditorTable}>
<colgroup>
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/link-dialog/LinkDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
>
<div className={styles.formField}>
Expand Down

0 comments on commit 9201e02

Please sign in to comment.