From eca9649be3c43b5e4ff4532bf0f832dcf26cc34a Mon Sep 17 00:00:00 2001 From: RoccoSmit Date: Sat, 24 Aug 2024 08:48:16 +1000 Subject: [PATCH] fix: cancel removes memo cache (#3826) Clear local storage record of memo changes if chanes to a memo are cancelled --- web/src/components/MemoEditor/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx index 6b54a736..a3f3086d 100644 --- a/web/src/components/MemoEditor/index.tsx +++ b/web/src/components/MemoEditor/index.tsx @@ -53,7 +53,7 @@ interface State { } const MemoEditor = (props: Props) => { - const { className, cacheKey, memoName, parentMemoName, autoFocus, onConfirm } = props; + const { className, cacheKey, memoName, parentMemoName, autoFocus, onConfirm, onCancel } = props; const t = useTranslate(); const { i18n } = useTranslation(); const workspaceSettingStore = useWorkspaceSettingStore(); @@ -364,6 +364,14 @@ const MemoEditor = (props: Props) => { }); }; + const handleCancelBtnClick = () => { + localStorage.removeItem(contentCacheKey); + + if (onCancel) { + onCancel(); + } + }; + const handleEditorFocus = () => { editorRef.current?.focus(); }; @@ -457,7 +465,7 @@ const MemoEditor = (props: Props) => {
{props.onCancel && ( - )}