Skip to content

Commit 43ad122

Browse files
author
Clauderic Demers
committed
fix: copy canvas content into cloned node
1 parent cc1f4ca commit 43ad122

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/SortableContainer/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,21 @@ export default function sortableContainer(
271271
top: window.pageYOffset,
272272
};
273273

274-
const fields = node.querySelectorAll('input, textarea, select');
274+
const fields = node.querySelectorAll('input, textarea, select, canvas');
275275
const clonedNode = node.cloneNode(true);
276276
const clonedFields = [
277-
...clonedNode.querySelectorAll('input, textarea, select'),
277+
...clonedNode.querySelectorAll('input, textarea, select, canvas'),
278278
];
279279

280280
clonedFields.forEach((field, i) => {
281281
if (field.type !== 'file' && fields[index]) {
282282
field.value = fields[i].value;
283283
}
284+
285+
if (field.tagName === NodeType.Canvas) {
286+
const destCtx = field.getContext('2d');
287+
destCtx.drawImage(fields[index], 0, 0);
288+
}
284289
});
285290

286291
this.helper = this.helperContainer.appendChild(clonedNode);

0 commit comments

Comments
 (0)