Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix(web): keep blurred memo header interactive (#6269)

周耕毅(Ryan Chou)143f224cdd85
diff --git a/web/src/components/MemoView/components/MemoBody.tsx b/web/src/components/MemoView/components/MemoBody.tsx
index 901d500b9..669fc3e91 100644
--- a/web/src/components/MemoView/components/MemoBody.tsx
+++ b/web/src/components/MemoView/components/MemoBody.tsx
@@ -17,7 +17,7 @@ import type { MemoBodyProps } from "../types";
const BlurOverlay: React.FC<{ onClick?: () => void }> = ({ onClick }) => {
const t = useTranslate();
return (
- <div className="absolute inset-0 z-10 flex items-center justify-center pt-4">
+ <div className="absolute inset-0 z-10 flex items-center justify-center">
<Button type="button" variant="outline" size="sm" onClick={onClick}>
<EyeIcon className="size-3.5" strokeWidth={1.8} />
{t("memo.click-to-show-sensitive-content")}
@@ -40,40 +40,43 @@ const MemoBody: React.FC<MemoBodyProps> = ({ compact }) => {
const { visual, audio, docs } = useMemo(() => separateAttachments(attachmentOnlyItems), [attachmentOnlyItems]);
return (
- <>
- <div
- className={cn(
- "w-full flex flex-col justify-start items-start gap-2",
- blurred && !showBlurredContent && "blur-lg transition-all duration-200",
- )}
- >
- {/* Compact bounds the whole body — attachments included — behind one Show more.
- Reactions stay outside so they never hide under the fade. */}
- <ClampedSection enabled={Boolean(compact)}>
- <MemoContent
- memoName={memo.name}
- parentPage={parentPage}
- content={memo.content}
- attachments={memo.attachments}
- onClick={handleMemoContentClick}
- onDoubleClick={handleMemoContentDoubleClick}
- compact={Boolean(compact)}
- />
- <AttachmentGallery visual={visual} onImagePreview={openPreview} />
- <MemoMetadataRows
- audio={audio}
- docs={docs}
- relations={referencedMemos}
- currentMemoName={memo.name}
- parentPage={parentPage}
- location={memo.location}
- />
- </ClampedSection>
- <MemoReactionListView memo={memo} reactions={memo.reactions} />
+ <div className="w-full flex flex-col justify-start items-start gap-2">
+ <div data-slot="memo-body" className="relative w-full">
+ <div
+ className={cn(
+ "w-full flex flex-col justify-start items-start gap-2",
+ blurred && !showBlurredContent && "blur-lg transition-all duration-200",
+ )}
+ >
+ {/* Compact bounds the whole body — attachments included — behind one Show more.
+ Reactions stay outside so they never hide under the fade. */}
+ <ClampedSection enabled={Boolean(compact)}>
+ <MemoContent
+ memoName={memo.name}
+ parentPage={parentPage}
+ content={memo.content}
+ attachments={memo.attachments}
+ onClick={handleMemoContentClick}
+ onDoubleClick={handleMemoContentDoubleClick}
+ compact={Boolean(compact)}
+ />
+ <AttachmentGallery visual={visual} onImagePreview={openPreview} />
+ <MemoMetadataRows
+ audio={audio}
+ docs={docs}
+ relations={referencedMemos}
+ currentMemoName={memo.name}
+ parentPage={parentPage}
+ location={memo.location}
+ />
+ </ClampedSection>
+ </div>
+
+ {blurred && !showBlurredContent && <BlurOverlay onClick={toggleBlurVisibility} />}
</div>
- {blurred && !showBlurredContent && <BlurOverlay onClick={toggleBlurVisibility} />}
- </>
+ <MemoReactionListView memo={memo} reactions={memo.reactions} />
+ </div>
);
};
diff --git a/web/tests/memo-body-compact.test.tsx b/web/tests/memo-body-compact.test.tsx
index 6c75ff7d4..3f0e956cb 100644
--- a/web/tests/memo-body-compact.test.tsx
+++ b/web/tests/memo-body-compact.test.tsx
@@ -9,11 +9,12 @@ const mockState = vi.hoisted(() => ({
content: "",
relations: [],
attachments: [],
- reactions: [],
+ reactions: [] as Array<{ reactionType: string; creator: string }>,
},
blurred: false,
showBlurredContent: false,
toggleBlurVisibility: vi.fn(),
+ reactionClick: vi.fn(),
}));
vi.mock("@/utils/i18n", () => ({
@@ -34,7 +35,12 @@ vi.mock("@/components/MemoMetadata", () => ({
}));
vi.mock("@/components/MemoReactionListView", () => ({
- MemoReactionListView: () => null,
+ MemoReactionListView: ({ memo }: { memo: { reactions: unknown[] } }) =>
+ memo.reactions.length > 0 ? (
+ <button type="button" aria-label="memo-reaction" onClick={mockState.reactionClick}>
+ Reaction
+ </button>
+ ) : null,
}));
vi.mock("@/components/MemoView/hooks", () => ({
@@ -57,18 +63,19 @@ vi.mock("@/components/MemoView/MemoViewContext", () => ({
}),
}));
-const createMemo = (content: string) => ({
+const createMemo = (content: string, reactions: Array<{ reactionType: string; creator: string }> = []) => ({
name: "memos/1",
content,
relations: [],
attachments: [],
- reactions: [],
+ reactions,
});
afterEach(() => {
mockState.blurred = false;
mockState.showBlurredContent = false;
mockState.toggleBlurVisibility.mockReset();
+ mockState.reactionClick.mockReset();
vi.restoreAllMocks();
});
@@ -115,4 +122,34 @@ describe("<MemoBody /> compact body clamp", () => {
fireEvent.click(revealButton);
expect(mockState.toggleBlurVisibility).toHaveBeenCalledOnce();
});
+
+ it("scopes the sensitive-content overlay to the memo body", () => {
+ mockState.blurred = true;
+ mockState.memo = createMemo("sensitive content");
+
+ render(<MemoBody compact={false} />);
+
+ const revealButton = screen.getByRole("button", { name: "memo.click-to-show-sensitive-content" });
+ const memoBody = revealButton.closest('[data-slot="memo-body"]');
+
+ expect(memoBody).not.toBeNull();
+ expect(memoBody).toHaveClass("relative", "w-full");
+ });
+
+ it("keeps reactions interactive while sensitive content is blurred", () => {
+ mockState.blurred = true;
+ mockState.memo = createMemo("sensitive content", [{ reactionType: "👍", creator: "users/alice" }]);
+
+ render(<MemoBody compact={false} />);
+
+ const reaction = screen.getByRole("button", { name: "memo-reaction" });
+ const blurredContent = screen.getByText("sensitive content").closest(".blur-lg");
+
+ expect(blurredContent).not.toBeNull();
+ expect(blurredContent).not.toContainElement(reaction);
+ expect(reaction.closest('[data-slot="memo-body"]')).toBeNull();
+
+ fireEvent.click(reaction);
+ expect(mockState.reactionClick).toHaveBeenCalledOnce();
+ });
});