From bc50d62cf61a850dd10ffb1012aa687474d7fa4d Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 23 Apr 2024 11:39:10 +0200 Subject: [PATCH] =?UTF-8?q?:bug:=20Fix=20bug=20when=20removing=20first=20m?= =?UTF-8?q?essage=20from=20create=20chat=20comp=20a=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1457 --- apps/builder/src/components/TableList.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/builder/src/components/TableList.tsx b/apps/builder/src/components/TableList.tsx index 89d2ef55b..7f1a8f8d6 100644 --- a/apps/builder/src/components/TableList.tsx +++ b/apps/builder/src/components/TableList.tsx @@ -44,7 +44,8 @@ export const TableList = ({ onItemsChange, }: Props) => { const [items, setItems] = useState( - initialItems ?? (hasDefaultItem ? ([defaultItem] as ItemWithId[]) : []) + addIdsIfMissing(initialItems) ?? + (hasDefaultItem ? ([defaultItem] as ItemWithId[]) : []) ) const [showDeleteIndex, setShowDeleteIndex] = useState(null) @@ -183,3 +184,9 @@ export const TableList = ({ ) } + +const addIdsIfMissing = (items?: T[]): ItemWithId[] | undefined => + items?.map((item) => ({ + id: createId(), + ...item, + }))