Skip to content

Commit 49fb968

Browse files
committed
Re-enabled the selection highlight by restoring the focus ring utilities and the shortcutActive-based accent styling on the memo card wrapper
Closes #5281
1 parent 8659f69 commit 49fb968

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

web/src/components/MemoView/MemoView.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { observer } from "mobx-react-lite";
2-
import { memo, useMemo, useRef, useState } from "react";
2+
import { memo, useEffect, useMemo, useRef, useState } from "react";
33
import { cn } from "@/lib/utils";
44
import type { Memo } from "@/types/proto/api/v1/memo_service_pb";
55
import MemoEditor from "../MemoEditor";
@@ -33,6 +33,7 @@ const MemoView: React.FC<Props> = observer((props: Props) => {
3333
const { memo: memoData, className } = props;
3434
const cardRef = useRef<HTMLDivElement>(null);
3535
const [reactionSelectorOpen, setReactionSelectorOpen] = useState(false);
36+
const [shortcutActive, setShortcutActive] = useState(false);
3637

3738
const creator = useMemoCreator(memoData.creator);
3839
const { commentAmount, relativeTimeFormat, isArchived, readonly, isInMemoDetailPage, parentPage } = useMemoViewDerivedState(
@@ -59,6 +60,17 @@ const MemoView: React.FC<Props> = observer((props: Props) => {
5960
onArchive: archiveMemo,
6061
});
6162

63+
useEffect(() => {
64+
if (showEditor || readonly) {
65+
setShortcutActive(false);
66+
}
67+
}, [showEditor, readonly]);
68+
69+
const handleShortcutActivation = (active: boolean) => {
70+
if (readonly) return;
71+
setShortcutActive(active);
72+
};
73+
6274
const contextValue = useMemo(
6375
() => ({
6476
memo: memoData,
@@ -90,7 +102,13 @@ const MemoView: React.FC<Props> = observer((props: Props) => {
90102

91103
return (
92104
<MemoViewContext.Provider value={contextValue}>
93-
<article className={cn(MEMO_CARD_BASE_CLASSES, className)} ref={cardRef} tabIndex={readonly ? -1 : 0}>
105+
<article
106+
className={cn(MEMO_CARD_BASE_CLASSES, shortcutActive && !showEditor && "border-ring ring-2 ring-ring bg-accent/10", className)}
107+
ref={cardRef}
108+
tabIndex={readonly ? -1 : 0}
109+
onFocus={() => handleShortcutActivation(true)}
110+
onBlur={() => handleShortcutActivation(false)}
111+
>
94112
<MemoHeader
95113
showCreator={props.showCreator}
96114
showVisibility={props.showVisibility}

0 commit comments

Comments
 (0)