From a12ca9fed88abc9e92e2e0d05e27a4433a1be72a Mon Sep 17 00:00:00 2001 From: arpitnath Date: Wed, 10 Apr 2024 02:13:39 +0530 Subject: [PATCH] Remove requestIdleCallback to resolve drag-and-drop UI freezing This commit removes the use of handleLowPriorityWork with requestIdleCallback, which previously deferred state updates of draggable components to the browser's idle periods. This change ensures immediate state updates during drag-and-drop actions, providing a smoother and more responsive user experience. --- frontend/src/Editor/Container.jsx | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/frontend/src/Editor/Container.jsx b/frontend/src/Editor/Container.jsx index 6787110c8a..416e7a6b0e 100644 --- a/frontend/src/Editor/Container.jsx +++ b/frontend/src/Editor/Container.jsx @@ -594,23 +594,21 @@ export const Container = ({ ...updatedBoxes, }; - handleLowPriorityWork(() => { - const diffState = diff(boxes, newBoxes); + const diffState = diff(boxes, newBoxes); - setBoxes((prev) => { - const updatedComponentsAsperDiff = Object.keys(diffState).reduce((acc, key) => { - const component = newBoxes[key]; - if (component) { - acc[key] = component; - } - return acc; - }, {}); + setBoxes((prev) => { + const updatedComponentsAsperDiff = Object.keys(diffState).reduce((acc, key) => { + const component = newBoxes[key]; + if (component) { + acc[key] = component; + } + return acc; + }, {}); - return { - ...prev, - ...updatedComponentsAsperDiff, - }; - }); + return { + ...prev, + ...updatedComponentsAsperDiff, + }; }); updateCanvasHeight(newBoxes);