From e291496b8fd5d2c665130c7a8405e198fc4231a7 Mon Sep 17 00:00:00 2001 From: Milo Moisson Date: Fri, 15 Sep 2023 19:37:21 +0200 Subject: [PATCH] feat: add use effect to register dialog text area default value change --- src/components/digests/block-card/text-card/TextCard.tsx | 2 +- src/components/digests/dialog/EditTextBlockDialog.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/digests/block-card/text-card/TextCard.tsx b/src/components/digests/block-card/text-card/TextCard.tsx index a9180e7..4a73aa5 100644 --- a/src/components/digests/block-card/text-card/TextCard.tsx +++ b/src/components/digests/block-card/text-card/TextCard.tsx @@ -66,7 +66,7 @@ export default function BlockTextCard({ block, isEditable = false }: Props) { setIsOpen={setIsEditDialogOpen} bookmarkDigest={block} defaultValues={{ - ...(block.text && { text: block.text }), + text: block.text, }} /> diff --git a/src/components/digests/dialog/EditTextBlockDialog.tsx b/src/components/digests/dialog/EditTextBlockDialog.tsx index d2bc1f3..a8db7db 100644 --- a/src/components/digests/dialog/EditTextBlockDialog.tsx +++ b/src/components/digests/dialog/EditTextBlockDialog.tsx @@ -2,8 +2,6 @@ import { useTeam } from '@/contexts/TeamContext'; import useCustomToast from '@/hooks/useCustomToast'; import useTransitionRefresh from '@/hooks/useTransitionRefresh'; import api from '@/lib/api'; -import { getTweetId, isTwitterLink } from '@/utils/link'; -import { BookmarkDigestStyle } from '@prisma/client'; import { AxiosError, AxiosResponse } from 'axios'; import { useParams } from 'next/navigation'; import React, { useEffect } from 'react'; @@ -41,6 +39,10 @@ export default function EditTextBlockDialog({ const { successToast, errorToast } = useCustomToast(); const { isRefreshing, refresh } = useTransitionRefresh(); + useEffect(() => { + reset(defaultValues); + }, [defaultValues, reset]); + const params = useParams(); const { id: teamId } = useTeam();