Skip to content

Commit

Permalink
fix: onChange event not fired after calling editor.set(...) (see #…
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Nov 8, 2023
1 parent 2eec4e6 commit afaca42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/lib/components/JSONEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@
// new editor id -> will re-create the editor
instanceId = uniqueId()
content = newContent
await tick() // await re-render (creating the new editor)
await tick() // await rerender
// update content *after* re-render, so that the new editor will trigger an onChange event
content = newContent
}
export async function update(updatedContent: Content): Promise<void> {
Expand Down
3 changes: 1 addition & 2 deletions tools/develop-vanilla.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,7 @@
updated: ':)'
}
const str = JSON.stringify(updatedJson, null, 2)
const index = str.lastIndexOf('}')
const invalidStr = str.slice(0, index) + ']' + str.slice(index + 1)
const invalidStr = str + '['
testEditor.update({ text: invalidStr })
}

Expand Down

0 comments on commit afaca42

Please sign in to comment.