Possible to temporarily disable all mutation observation?

I have a problem of the kind that is normally solved by node-view.ignoreMutation but in this case, the UI component I’m using (the combobox from Ark UI) seems to be doing a bunch of dom mutations outside of its own element. The combobox popup won’t open because ProseMirror re-renders the node-view and everything is reset.

I think it does this for accessibility reasons - it can add stuff like aria-hidden=“true” to elements that get obscured by a popup.

Actually in my case they seem to be no-op mutations: I see a load of elements flash in devtools but I don’t see any actual changes. Seems it’s enough to trigger the prosemirror rebuild of the node-view.

I realise this is not a prosemirror issue. Just wondering if anyone can think of a workaround. My first thought was handleDOMEvents but the dom mutation observer does not work via the events system.

Thanks in advance for any help.

1 Like

Try this

// @ts-ignore
view.domObserver.stop()
// change dom
// @ts-ignore
view.domObserver.start()

This isn’t really something that the library accounts for. If your combobox is creating a bunch of no-op mutations, maybe the problem is with that library, and swapping it out or fixing it would be the way to handle this?

1 Like

However, I do have a use case that requires this functionality. My editor’s style changes according to the playback time of the video. This style is applied to a mark, but I can’t use decorations because they get split by other marks, which messes up the style. I also can’t use the mark’s attr because this is a temporary state, and I don’t want to modify the doc. So, I used the method I described above to temporarily modify the style. In this situation, if I don’t hack it, what should I do?

You could put the mark at the very start of your list of marks in the schema, to make sure it doesn’t get split by other marks. Other than that, I don’t have any suggestions for you.