From f0fba23c34030342229f7b2fe5848445c7079103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 8 Oct 2026 21:56:24 +0200 Subject: [PATCH] refactor(insights): leave the arrange editor's sorted rows to the compiler The draft now comes out of a render-time reconcile, so a manual memo over it could not be preserved and the compiler skipped the component. --- src/components/insights/insights-edit-mode.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/insights/insights-edit-mode.tsx b/src/components/insights/insights-edit-mode.tsx index fb49d9ad4..3d762464d 100644 --- a/src/components/insights/insights-edit-mode.tsx +++ b/src/components/insights/insights-edit-mode.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect, useMemo, useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import Link from "next/link"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { toast } from "sonner"; @@ -50,6 +50,7 @@ import { arrangementSignature, reconcileArrangeDraft, seedArrangeDraft, + sortByOrder, } from "@/lib/insights-arrange-draft"; import { apiDelete, apiPut } from "@/lib/api/api-fetch"; import { @@ -222,10 +223,7 @@ export function InsightsEditMode({ arrangementSignature(draftSections) !== arrangementSignature(layout.sections); - const sections = useMemo( - () => [...draftSections].sort((a, b) => a.order - b.order), - [draftSections], - ); + const sections = sortByOrder(draftSections); const sectionIds = sections.map((s) => s.id); function toggleSection(id: InsightsSectionId, visible: boolean) {