From 8077263ecf8fa8653aed1cdf866216a8d078b4cd Mon Sep 17 00:00:00 2001 From: abdou6666 Date: Fri, 28 Mar 2025 10:11:24 +0100 Subject: [PATCH] fix: custom plugins displayed sorted --- .../src/components/visual-editor/CustomBlocks.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/visual-editor/CustomBlocks.tsx b/frontend/src/components/visual-editor/CustomBlocks.tsx index 249cbe78..cf17cabb 100644 --- a/frontend/src/components/visual-editor/CustomBlocks.tsx +++ b/frontend/src/components/visual-editor/CustomBlocks.tsx @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -7,6 +7,7 @@ */ import { Grid } from "@mui/material"; +import { useMemo } from "react"; import PluginIcon from "@/app-components/svg/toolbar/PluginIcon"; import { useFind } from "@/hooks/crud/useFind"; @@ -17,18 +18,22 @@ import { Block, StyledTitle } from "./Aside"; export const CustomBlocks = () => { const { t } = useTranslate(); - const { data: customBlocks } = useFind( + const { data: customBlocks = [] } = useFind( { entity: EntityType.CUSTOM_BLOCK }, { hasCount: false }, ); + const memoizedCustomBlock = useMemo( + () => customBlocks.sort((a, b) => a.id.localeCompare(b.id)), + [customBlocks], + ); - return customBlocks?.length ? ( + return memoizedCustomBlock.length ? ( <> {t("title.custom_blocks")} - {customBlocks?.map((customBlock) => ( + {memoizedCustomBlock.map((customBlock) => (