josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
887 stars 109 forks source link

Mode switching issue in React #482

Open MatthewAMartin opened 1 week ago

MatthewAMartin commented 1 week ago

Hi!

I'm using this as part of a React-based page editor I've been building with Editor.js. However, I'm having one particular issue with mode switching. For the first instance of the jsoneditor on the page, if you try to switch modes via the menu the following errors are thrown:

Screenshot 2024-09-09 at 9 01 29 AM

This then breaks mode switching on all other instances as well. But if you never interact with the mode switch on the first instance, the following instances will work as intended.

Any ideas as to what could be causing this issue?

Here's my current implementation:

Screenshot 2024-09-09 at 9 00 04 AM

josdejong commented 1 week ago

THanks for reporting. Can you create a minimal example on for example StackBlitz so we can demonstrate the issue? For example in the React example https://codesandbox.io/p/sandbox/svelte-jsoneditor-react-59wxz switching mode works fine.