From a6073f20beec096c2c2fa906bacbd7da69ccdc89 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Tue, 31 Dec 2024 16:25:31 +0800 Subject: [PATCH] fix(core): split view reordering crash --- .../workbench/view/split-view/split-view.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/frontend/core/src/modules/workbench/view/split-view/split-view.tsx b/packages/frontend/core/src/modules/workbench/view/split-view/split-view.tsx index 6ff0011e0bc23..c2e9fd930e6f2 100644 --- a/packages/frontend/core/src/modules/workbench/view/split-view/split-view.tsx +++ b/packages/frontend/core/src/modules/workbench/view/split-view/split-view.tsx @@ -50,6 +50,10 @@ export const SplitView = ({ const { appSettings } = useAppSettingHelper(); const workbench = useService(WorkbenchService).workbench; + // blocksuite's lit host element has an issue on remounting. + // Add a workaround here to force remounting after dropping. + const [visible, setVisibility] = useState(true); + const sensors = useSensors( useSensor( PointerSensor, @@ -102,6 +106,10 @@ export const SplitView = ({ const fromIndex = views.findIndex(v => v.id === active.id); const toIndex = views.findIndex(v => v.id === over?.id); onMove?.(fromIndex, toIndex); + setVisibility(false); + setTimeout(() => { + setVisibility(true); + }); } }, [onMove, views] @@ -121,11 +129,13 @@ export const SplitView = ({ onDragEnd={handleDragEnd} > - {views.map((view, index) => ( - - {resizeHandleRenderer(view, index)} - - ))} + {views.map((view, index) => + visible ? ( + + {resizeHandleRenderer(view, index)} + + ) : null + )}