TeemuKoivisto / prosemirror-dev-toolkit

Injectable developer tools for ProseMirror rich-text editors implemented in Svelte and TypeScript.
https://teemukoivisto.github.io/prosemirror-dev-toolkit/
MIT License
115 stars 6 forks source link

Extension causes bug with NodeView .update not being called #73

Closed tslocke closed 7 months ago

tslocke commented 8 months ago

(reposted from discuss.prosemirror.net)

I have a problem in my app of a .update method not getting called. I’ve reduced the issue to a minimal example (single html file). It turns out to only happen when the dev-toolkit is active.

I have a doc with just one node, with a node-view that displays a button. I would expect that on clicking the button I would see a message in the console but I don’t.

During testing I noticed things seem to behave properly when the editor is not mounted in the DOM. I’ve included a demonstration of this in the example code (so in fact I the example code should display two messages in the console but I only see one)

https://gist.github.com/tslocke/466271841ea57f911fdddd917f4d478e

TeemuKoivisto commented 7 months ago

Hey @tslocke thanks for the bug report!

I noticed as well the patching of update method sometimes tends to flake — for whatever reason.

I added a demo for the site app but I can't reproduce the exact same behavior. If you could tinker with it to make the bug appear that would help a lot. Is this behavior tied to the Chrome extension and/or the additional EditorView?

https://github.com/TeemuKoivisto/prosemirror-dev-toolkit/tree/nodeview-bug

I have put off refactoring the extension for a while now since it's such a nightmare to debug and test. But suppose this could be a good time for it.

TeemuKoivisto commented 7 months ago

Okay I fixed the issue with the globals https://github.com/TeemuKoivisto/prosemirror-dev-toolkit/issues/74 and I think it has fixed this as well. At least running that gist I get now both

update mounted
update headless

@tslocke is this correct?

tslocke commented 7 months ago

Hey @TeemuKoivisto. I was going to have a look at this today, as you said you couldn't reproduce the problem, but it seems you've beaten me to it : ) Yes -- if those two lines show up in the console it seems like the problem is fixed. I'll let you know if the full problem (i.e. in my project, not the minimal version) is fixed once a new extension version is available.

Thanks!

TeemuKoivisto commented 7 months ago

I assume @tslocke this was fixed so I'll close the issue.

tslocke commented 7 months ago

Hey @TeemuKoivisto. I hadn't responded because I wasn't sure if the new extension version was released. Just double-checked now and it seems to be working great. Thanks : )

TeemuKoivisto commented 7 months ago

Great!