From e1443ae4bf46c3bdf23ea837e9677be1f27218d7 Mon Sep 17 00:00:00 2001 From: Gabriel Vanrenen Date: Tue, 1 Oct 2024 14:31:05 -0600 Subject: [PATCH] fixing issue with a form element sometimes getting deleted when you insert a new one. --- src/preview.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/preview.jsx b/src/preview.jsx index 5a5c6ca4..9a8ee7b7 100644 --- a/src/preview.jsx +++ b/src/preview.jsx @@ -220,7 +220,10 @@ export default class Preview extends React.Component { moveCard(dragIndex, hoverIndex) { const { data } = this.state; const dragCard = data[dragIndex]; - this.saveData(dragCard, dragIndex, hoverIndex); + // happens sometimes when you click to insert a new item from the toolbox + if (dragCard !== undefined) { + this.saveData(dragCard, dragIndex, hoverIndex); + } } // eslint-disable-next-line no-unused-vars