Stabilize sidebar settling animations (#4280)
This commit is contained in:
1 parent
020179c19a
commit
18b468871e
1 file changed
+30
-14
@@ -129,10 +129,6 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
|
||||
// False on environments whose server predates thread.settle/unsettle:
|
||||
// the lifecycle affordances hide entirely rather than fail on click.
|
||||
settlementSupported: boolean;
|
||||
// Marks where active work transitions into history: a quiet labeled
|
||||
// rule above the first settled row, so the tail reads as a named zone
|
||||
// rather than an unexplained gap.
|
||||
showSettledGap?: boolean;
|
||||
isActive: boolean;
|
||||
jumpLabel: string | null;
|
||||
currentEnvironmentId: string | null;
|
||||
@@ -398,12 +394,6 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
|
||||
data-thread-item
|
||||
className="list-none [content-visibility:auto] [contain-intrinsic-size:auto_34px]"
|
||||
>
|
||||
{props.showSettledGap ? (
|
||||
<div aria-hidden className="mb-1 mt-3 flex items-center gap-2 px-2.5">
|
||||
<span className="text-[10px] font-medium text-muted-foreground/50">Settled</span>
|
||||
<span className="h-px flex-1 bg-border/60" />
|
||||
</div>
|
||||
) : null}
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
@@ -1529,7 +1519,7 @@ export default function SidebarV2() {
|
||||
) : null}
|
||||
<SidebarGroup className="min-h-0 flex-1 overflow-y-auto px-2 py-1">
|
||||
<ul ref={attachListAutoAnimateRef} className="flex flex-col gap-px">
|
||||
{orderedThreads.map((thread, threadIndex) => {
|
||||
{orderedThreads.flatMap((thread, threadIndex) => {
|
||||
const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
|
||||
const isSettledRow = settledThreadKeys.has(threadKey);
|
||||
// Settled is the ONLY thing that collapses a row: every
|
||||
@@ -1544,10 +1534,14 @@ export default function SidebarV2() {
|
||||
scopedThreadKey(scopeThreadRef(previousThread.environmentId, previousThread.id)),
|
||||
);
|
||||
const showSettledGap = !isCard && previousWasCard;
|
||||
return (
|
||||
const row = (
|
||||
<SidebarV2Row
|
||||
showSettledGap={showSettledGap}
|
||||
key={threadKey}
|
||||
// Keyed per variant on purpose: when a thread settles, the
|
||||
// card fades out in place and the slim row fades in at its
|
||||
// settled position instead of one element FLIP-sliding
|
||||
// through every row in between (rows here are translucent,
|
||||
// so a crossing row reads as text painted over text).
|
||||
key={`${threadKey}:${isCard ? "card" : "slim"}`}
|
||||
thread={thread}
|
||||
variant={isCard ? "card" : "slim"}
|
||||
// Every settled row can un-settle: explicit settles clear
|
||||
@@ -1582,6 +1576,28 @@ export default function SidebarV2() {
|
||||
onChangeRequestState={handleChangeRequestState}
|
||||
/>
|
||||
);
|
||||
if (!showSettledGap) return [row];
|
||||
// The divider is its own keyed list item (not part of the first
|
||||
// settled row): it keeps one stable DOM node at the boundary,
|
||||
// so settling a thread slides it instead of teleporting it
|
||||
// along with whichever row happens to be first in the tail —
|
||||
// and row heights stay independent of neighbor classification.
|
||||
return [
|
||||
<li
|
||||
key="settled-divider"
|
||||
aria-hidden
|
||||
data-thread-selection-safe
|
||||
className="list-none"
|
||||
>
|
||||
<div className="mb-1 mt-3 flex items-center gap-2 px-2.5">
|
||||
<span className="text-[10px] font-medium text-muted-foreground/50">
|
||||
Settled
|
||||
</span>
|
||||
<span className="h-px flex-1 bg-border/60" />
|
||||
</div>
|
||||
</li>,
|
||||
row,
|
||||
];
|
||||
})}
|
||||
{hiddenSettledCount > 0 ? (
|
||||
<li className="list-none">
|
||||
|
||||
Reference in new issue
Block a user