Skip to content

Commit 5c36b3e

Browse files
committed
fix(web): undo notice fades in and out and keeps the undo link emphasized
1 parent b541d9c commit 5c36b3e

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎apps/web/src/components/sidebar/SidebarThreadUndoNotice.tsx‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useAtomValue } from "@effect/atom-react";
2-
import { useEffect } from "react";
2+
import { useEffect, useState } from "react";
33

44
import { undoLatestThreadAction, useThreadUndoNotice } from "../../hooks/showThreadUndoNotice";
55
import { shortcutLabelForCommand } from "../../keybindings";
@@ -25,17 +25,27 @@ export function SidebarThreadUndoNotice({ className }: { className?: string }) {
2525
else cancelAnnouncement("thread-undo-notice");
2626
}, [summary, undoLabel]);
2727

28-
if (!summary) return null;
28+
// Keeps the last text on screen while it fades out, then unmounts on transitionend.
29+
const [shownSummary, setShownSummary] = useState(summary);
30+
if (summary && summary !== shownSummary) setShownSummary(summary);
31+
const text = summary ?? shownSummary;
32+
if (!text) return null;
2933

3034
return (
3135
<div
3236
role="group"
33-
className={cn("truncate px-2 text-2xs leading-6 text-sidebar-muted-foreground", className)}
37+
aria-hidden={!summary}
38+
inert={!summary}
39+
onTransitionEnd={(event) => {
40+
if (!summary && event.target === event.currentTarget) setShownSummary(null);
41+
}}
42+
className={cn(
43+
"truncate px-2 text-2xs leading-6 text-sidebar-muted-foreground transition-opacity duration-200 ease-out starting:opacity-0",
44+
!summary && "opacity-0",
45+
className,
46+
)}
3447
>
35-
{summary},{" "}
36-
<InlineButton onClick={undoLatestThreadAction} tone="inherit">
37-
{undoLabel}
38-
</InlineButton>
48+
{text}, <InlineButton onClick={undoLatestThreadAction}>{undoLabel}</InlineButton>
3949
</div>
4050
);
4151
}

‎apps/web/src/components/ui/button.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ const inlineButtonVariants = cva(
103103
variants: {
104104
tone: {
105105
default: "text-foreground",
106-
inherit: "text-inherit",
107106
muted: "text-muted-foreground hover:text-foreground",
108107
destructive: "text-destructive/80 hover:text-destructive",
109108
picker:

0 commit comments

Comments
 (0)