Using with turbolinks

Hi I am trying to implement a simple PM textarea solution in an app that uses Turbolinks. The problem I am running into is that I do not know how to properly destroy the menu that is built using the buildMenuItems from the example-setup. There seems to be an event added to scroll that throws errors after a page change:

Uncaught TypeError: Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 1 present. It is complaining about this line in the menu: https://github.com/ProseMirror/prosemirror-menu/blob/1.0.4/src/menubar.js#L63

Basically I store all my page editors in a global array, and on a turbolinks page change I try and destroy them like so:

document.addEventListener("turbolinks:before-cache", () => {
  prose_editors.forEach(function(editor) {
    editor.destroy()
    editor = null
  })
});

Any help in what else I may need to be doing in order to remove all the page editors including event handlers?

destroy should remove the event handlers. The error message looks strange—removeEventListener is being passed two arguments on the line you linked.

For some reason the code that is being run in my browser is only passing 1 argument:

if (!(root.body || root).contains(this$1.wrapper)) {
  potentialScrollers.forEach(function (el) { return el.removeEventListener(this$1.scrollFunc); });
} else {
  ...
}

Have you tried looking at the version to see if you’re actually running the current code (1.0.4)?

It seems my yarn.lock was running 2 versions of prosemirror-menu. 1.0.1 and 1.0.4 Apparently it was choosing to run the older version with the bug in production. I’m not totally sure how this Yarn magic works, but upgrading Yarn, deleting the lock file and rebuilding everything seems to have nudged the old version out of there.

Thanks!