From 946df8e7149f10b1441b14e2b85ad8b37defbd15 Mon Sep 17 00:00:00 2001 From: Kaushik Dutta Date: Sat, 15 Mar 2025 17:43:16 +0800 Subject: [PATCH] [fix/editor]: generate unique id for text addition Previously, the text payload used a static id causing new text additions to overwrite the previous text. By removing the static id and generating a new id with generateId(), each text addition now creates a unique entry. --- src/pages/editor/constants/payload.ts | 2 -- src/pages/editor/menu-item/texts.tsx | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/editor/constants/payload.ts b/src/pages/editor/constants/payload.ts index 1009048..f5ca059 100644 --- a/src/pages/editor/constants/payload.ts +++ b/src/pages/editor/constants/payload.ts @@ -1,8 +1,6 @@ -import { generateId } from "@designcombo/timeline"; import { DEFAULT_FONT } from "./font"; export const TEXT_ADD_PAYLOAD = { - id: generateId(), display: { from: 0, to: 5000, diff --git a/src/pages/editor/menu-item/texts.tsx b/src/pages/editor/menu-item/texts.tsx index 37f2726..597de82 100644 --- a/src/pages/editor/menu-item/texts.tsx +++ b/src/pages/editor/menu-item/texts.tsx @@ -1,4 +1,5 @@ import { Button, buttonVariants } from "@/components/ui/button"; +import { generateId } from "@designcombo/timeline"; import { ADD_TEXT } from "@designcombo/state"; import { dispatch } from "@designcombo/events"; import { useIsDraggingOverTimeline } from "../hooks/is-dragging-over-timeline"; @@ -11,7 +12,10 @@ export const Texts = () => { const handleAddText = () => { dispatch(ADD_TEXT, { - payload: TEXT_ADD_PAYLOAD, + payload: { + ...TEXT_ADD_PAYLOAD, + id: generateId(), + }, options: {}, }); };