Skip to content

Commit

Permalink
fix(core): split view reordering crash
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Dec 31, 2024
1 parent 597b631 commit 127bb68
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export const SplitView = ({
const { appSettings } = useAppSettingHelper();
const workbench = useService(WorkbenchService).workbench;

const [visible, setVisibility] = useState(true);

const sensors = useSensors(
useSensor(
PointerSensor,
Expand Down Expand Up @@ -102,7 +104,15 @@ 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);
const timeoutId = setTimeout(() => {
setVisibility(true);
});
return () => {
clearTimeout(timeoutId);
};
}
return;
},
[onMove, views]
);
Expand All @@ -121,11 +131,13 @@ export const SplitView = ({
onDragEnd={handleDragEnd}
>
<SortableContext items={views} strategy={horizontalListSortingStrategy}>
{views.map((view, index) => (
<SplitViewPanel view={view} key={view.id} setSlots={setSlots}>
{resizeHandleRenderer(view, index)}
</SplitViewPanel>
))}
{views.map((view, index) =>
visible ? (
<SplitViewPanel view={view} key={view.id} setSlots={setSlots}>
{resizeHandleRenderer(view, index)}
</SplitViewPanel>
) : null
)}
</SortableContext>
</DndContext>

Expand Down

0 comments on commit 127bb68

Please sign in to comment.