interact.js icon indicating copy to clipboard operation
interact.js copied to clipboard

divs with contenteditable="true" are not editable

Open Nolski opened this issue 10 years ago • 3 comments

In the following example:

<div class="draggable">
    <div id="edit" contenteditable="true"></div>
</div>

The div with id="edit" will not behave normally as a div with contenteditable="true" would. I think the click event is somehow getting intercepted by interact.js. However an <input> element will work just fine.

Nolski avatar Sep 07 '16 16:09 Nolski

I've recently discovered this same issue as well, and I'm wondering if you found a solution? The best I've found so far is to manually disable/enable the draggable as a work around, but I'd love to hear if there is a better approach.

bryantabaird avatar Sep 13 '16 15:09 bryantabaird

More of a workaround but i've just been using a handle. Don't know if that suits your use.

HTML:

<div class="text-container drag-element">
    <div id="text1" class="handle text-handle">
        <!-- Handle contents -->
    </div>
    <div class="editdiv resize-element" contenteditable="true" style="width: 379px; height: 200px;">
    </div>
</div>

Javascript:

interact('.drag-element')
    .draggable({
        inertia: false,
        restrict: {
          restriction: "parent",
          endOnly: false,
          elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
        },
        autoScroll: true,
        onmove: dragMoveListener
    })
    .allowFrom('.handle');
interact('.resize-element')
    .resizable({
        edges: { left: true, right: true, bottom: true, top: false},
        onmove: resizeMoveListener
    });

dpekkle avatar Sep 16 '16 06:09 dpekkle

Other approaches that may work are to chain .preventDefault('never') on your interactable, though this may well cause other issues.

dpekkle avatar Sep 16 '16 13:09 dpekkle