ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.66k stars 336 forks source link

removeAttribute draggable on text node is causing issue. #1468

Closed JagadeepSai closed 4 months ago

JagadeepSai commented 4 months ago

Cause: Happens sometimes when selecting a text node at the start of the paragraph and then clicking anywhere else in the editor.

Debugger result. From deselectNode of clearNodeSelection :

function clearNodeSelection(view) {
  if (view.lastSelectedViewDesc) {
    if (view.lastSelectedViewDesc.parent) view.lastSelectedViewDesc.deselectNode();
    view.lastSelectedViewDesc = undefined;
  }
}
{
    key: "deselectNode",
    value: function deselectNode() {
      if (this.nodeDOM.nodeType == 1) this.nodeDOM.classList.remove("ProseMirror-selectednode");
      if (this.contentDOM || !this.node.type.spec.draggable) this.dom.removeAttribute("draggable");
    }
  }

In the above this.node.type.spec.draggable is undefined. this.dom is #text and doesn't have removeAttribute

Screenshot 2024-05-29 at 12 13 00 Screenshot 2024-05-29 at 12 13 45
marijnh commented 4 months ago

Attached patch should help.