diff --git a/packages/amis/src/renderers/Cards.tsx b/packages/amis/src/renderers/Cards.tsx index d2720b260..22c73b9b4 100644 --- a/packages/amis/src/renderers/Cards.tsx +++ b/packages/amis/src/renderers/Cards.tsx @@ -617,6 +617,7 @@ export default class Cards extends React.Component { destroyDragging() { this.sortable && this.sortable.destroy(); + this.sortable = undefined; } renderActions(region: string) { @@ -848,7 +849,14 @@ export default class Cards extends React.Component { } renderDragToggler() { - const {store, multiple, selectable, env, translate: __} = this.props; + const { + store, + multiple, + selectable, + env, + translate: __, + dragIcon + } = this.props; if (!store.draggable || store.items.length < 2) { return null; @@ -868,9 +876,14 @@ export default class Cards extends React.Component { e.preventDefault(); store.toggleDragging(); store.dragging && store.clear(); + store.dragging ? this.initDragging() : undefined; }} > - + {React.isValidElement(dragIcon) ? ( + dragIcon + ) : ( + + )} ); } @@ -904,9 +917,11 @@ export default class Cards extends React.Component { className: cx((card && card.className) || '', { 'is-checked': item.checked, 'is-modified': item.modified, - 'is-moved': item.moved + 'is-moved': item.moved, + 'drag-mode': store.dragging }), item, + key: index, itemIndex: item.index, multiple, selectable: store.selectable,