Vue.Draggable icon indicating copy to clipboard operation
Vue.Draggable copied to clipboard

Can't drag into empty list with footer

Open MarcelloTheArcane opened this issue 7 years ago • 12 comments

Jsfiddle link

It happens in the live demo, does that count?

Step by step scenario

I am trying to drag from one list into another empty list, but it doesn't let me. I know about setting a min-height, but my <draggable> elements have a footer, so I'm not sure what element I am supposed to set a min-height to, since the <draggable> has a non-zero height already.

Here is a demonstration using the docs:

image

image

I expect to be able to drag into an empty list that has a footer.

MarcelloTheArcane avatar Jul 08 '19 06:07 MarcelloTheArcane

@MarcelloTheArcane You should use props :emptyInsertThreshold="100" for 100px on your draggable comp.

You can insert on empty array, and the mouse will be reactive at 100 px, change value as you want...

works fine for me, here 's my exemple

<draggable
          :list="messages"
          group="composer"
          v-bind="dragOptions"
          :emptyInsertThreshold="500"
          @start="drag = true"
          @end="drag = false"
          @click="editText(text)"
          handle=".drag-handle"
        >... </draggable>```

xlanex6 avatar Jul 11 '19 09:07 xlanex6

@xlanex6 You solution won't work on table.

Uysim avatar Jul 18 '19 00:07 Uysim

It doesn't work for me... Also are you sure the prop should be cased like that? Apparently html ignores it

MarcelloTheArcane avatar Jul 18 '19 08:07 MarcelloTheArcane

Try: :empty-insert-threshold="100"

David-Desmaisons avatar Jul 18 '19 12:07 David-Desmaisons

Try: :empty-insert-threshold="100"

this seems to work for me, but even though the slot is set to footer the item gets added below the footer while dragging. After the drop, it's displaying properly again (above the footer). Maybe this will work if I add a min-height. I just have to figure it out.

keeev avatar Jul 22 '19 08:07 keeev

When a draggable is bound to an empty list, the inner transition-group - which is rendered as a span - will get a size of 6x22 px, no matter how you set the css or empty-insert-threshold. After many tries I still can not drop into an empty list.

James-Z-Tang avatar Sep 18 '19 17:09 James-Z-Tang

I solved this problem by using a placeholder in empty list. More work to be done in onEnd method in order to removed the placeholder item from non-empty list and add it to empty list. And on saving to DB the placeholder item also needs to be removed.

James-Z-Tang avatar Sep 18 '19 21:09 James-Z-Tang

I think this is possible on the official demo (NB: The example is titled wrong: they're footers, not headers), but we've found another issue:

It's (only?) possible to drag content underneath a footer, which I wouldn't expect to be possible. Dropping the content then snaps it back above the header, which is pretty jarring.

Nov-15-2019 13-16-32

alecgibson avatar Nov 15 '19 00:11 alecgibson

For what it's worth - this is because of a span element that provides the actual target for the eventual drop. I used CSS to style the span element giving it a full height to resolve. I have lanes (like a Kanban board) and thus the entire lane could be empty and yet the drag area should be the entire lane, not a 0px tall target. Happy to provide screenshots if it assists.

markadrake avatar May 22 '20 18:05 markadrake

@markadrake I'm working on a project similar to your Kanban board. Could you provide some screenshots on how you solved this issue? Thank you.

hmellin97 avatar Sep 03 '20 09:09 hmellin97

In case someone still has a problem with this or running into a problem, this is how I fixed it for my kanban board approach (simplified code):

with adding a class to draggable

 <draggable class="column">
      <transition-group type="transition">
        <div v-for="item in items" class="item" :key="item.id">
          <item :item="item"></item>
        </div>
      </transition-group>
    </draggable>

And like @markadrake mentioned, the span for the eventual drop needs a height/min-height:

<style lang="scss" scoped>
.column {
    & span {
        display: block; 
        //height: 100%;
        height: 300px;
    }
}
</style>

keeev avatar Feb 18 '21 15:02 keeev

@MarcelloTheArcane You should use props :emptyInsertThreshold="100" for 100px on your draggable comp.

You can insert on empty array, and the mouse will be reactive at 100 px, change value as you want...

works fine for me, here 's my exemple

<draggable
          :list="messages"
          group="composer"
          v-bind="dragOptions"
          :emptyInsertThreshold="500"
          @start="drag = true"
          @end="drag = false"
          @click="editText(text)"
          handle=".drag-handle"
        >... </draggable>```

Thank you so much man !!!

JonasFreireAlcantara avatar May 22 '21 02:05 JonasFreireAlcantara