Skip to content

Commit 0092213

Browse files
fix(loops): make detail page scroll and polish list rows (#3743)
Co-authored-by: posthog[bot] <206114724+posthog[bot]@users.noreply.github.com>
1 parent cc35bdc commit 0092213

4 files changed

Lines changed: 43 additions & 26 deletions

File tree

apps/code/snapshots.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,13 @@ snapshots:
569569
git-dialogs--sync-success--light:
570570
hash: v1.k4693efd2.8d79d77c9338aeaa73734836f0e17fde987f6d3239914f4013889d3110e5088d.Rq-w2o1uhes_a5hUWqMXeiDkfnoPCZPt932LkEQXCco
571571
loops-loopslistview--comprehensive--dark:
572-
hash: v1.k4693efd2.a9b9a8b23cca2079c3ced1878b6537ee9fbbdd0d3de205a9584fbe7d6875d405.dWfER84S8r_MU7EVDmjW8CuCf6lNhTx6RjfV_cNzKOA
572+
hash: v1.k4693efd2.3c2a6b87092674a3d395a6f5d36889ea231696d788b159f357be0926f3804c8a.Ihzlq7XIy9rRoA7DTbpLePlBhjP34o8ppgP__NXx-Yw
573573
loops-loopslistview--comprehensive--light:
574-
hash: v1.k4693efd2.9ff3f3787ef56ab9d1d39562eed6f19b6c9c1e7a6d79965fbf99fbac16ba33fb.DDuj_KZx0pcUxXwCgzNGFmCemCT1MuCzIQmbbPMgatw
574+
hash: v1.k4693efd2.42c2994def56651de08f5be20e98dbe67bfbdb03e7edd8bdf008401468c1653a.EnH7NwNkvclS7g5Htf7OCZuYEm7fI5W6hEr4DmwZC8I
575575
loops-loopslistview--long-mixed-list--dark:
576-
hash: v1.k4693efd2.683dedbfa7da3313eeaf52ff9e3cc7908af5c77173b1cad450b2acd61ac30cd4.YFm7fXVZSr29fa0R40pzq-FjRZrqIBEsIMiOiddB840
576+
hash: v1.k4693efd2.384486583f8d9b66a4bf1d9cc45036a07310cb9e1943ea5b52ff466f55a03d7b.F_sXrJ13XWHzAF8yhoKun_k4BY8Jcb3EDtT0L1I6nKw
577577
loops-loopslistview--long-mixed-list--light:
578-
hash: v1.k4693efd2.577fa23e3bc43f0ba033a59669fa73035ff2d65df1f994cf5753ac306ca830cf.r3v1hne0uC4dHpkzXriz6yzcA3fD2b8wD6ZLxA_0Fuo
578+
hash: v1.k4693efd2.d80a0c55c4490276df53f781ac88ed9d9c6ec282bc14ddb80140b3ddcc44d32f.L6hw9ZixUiyTFKOybYzmjfUSIOayvmhueMTcmYt-IWo
579579
scouts-scoutsfleetlist--filtered-to-you--dark:
580580
hash: v1.k4693efd2.a3af6e76ef36598eaa347bedc4430878ed62754660166398e0576a9978cd084b.x3Ky-O6HOw0srWdOmnnKJwFNpmGmQVWip0t7CwVaRXY
581581
scouts-scoutsfleetlist--filtered-to-you--light:

packages/ui/src/features/loops/components/LoopDetailView.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function LoopDetailView({ loopId }: { loopId: string }) {
105105

106106
if (isLoading) {
107107
return (
108-
<div className="mx-auto w-full max-w-5xl px-8 py-6">
108+
<div className="mx-auto w-full max-w-5xl px-8 py-8">
109109
<div className="h-24 animate-pulse rounded-(--radius-2) border border-border bg-(--gray-2)" />
110110
</div>
111111
);
@@ -116,16 +116,20 @@ export function LoopDetailView({ loopId }: { loopId: string }) {
116116
}
117117

118118
return (
119-
<div className="mx-auto w-full max-w-5xl px-8 py-6">
120-
<Flex direction="column" gap="5">
119+
<div className="h-full min-h-0 overflow-y-auto">
120+
<Flex
121+
direction="column"
122+
gap="5"
123+
className="mx-auto w-full max-w-5xl px-8 py-8"
124+
>
121125
<Flex direction="column" gap="3">
122126
<Button
123127
variant="link-muted"
124-
size="xs"
128+
size="sm"
125129
onClick={navigateToLoops}
126130
className="w-fit px-0"
127131
>
128-
<ArrowLeftIcon size={13} />
132+
<ArrowLeftIcon size={15} />
129133
Loops
130134
</Button>
131135

@@ -148,7 +152,7 @@ export function LoopDetailView({ loopId }: { loopId: string }) {
148152
/>
149153
<Button
150154
variant="outline"
151-
size="xs"
155+
size="sm"
152156
loading={runLoop.isPending}
153157
disabled={runLoop.isPending}
154158
onClick={handleRunNow}
@@ -157,14 +161,14 @@ export function LoopDetailView({ loopId }: { loopId: string }) {
157161
</Button>
158162
<Button
159163
variant="outline"
160-
size="xs"
164+
size="sm"
161165
onClick={() => navigateToEditLoop(loop.id)}
162166
>
163167
Edit
164168
</Button>
165169
<Button
166170
variant="destructive"
167-
size="xs"
171+
size="sm"
168172
onClick={() => setDeleteOpen(true)}
169173
>
170174
Delete
@@ -406,7 +410,7 @@ function InstructionsSection({ loop }: { loop: LoopSchemas.Loop }) {
406410
value={draft ?? loop.instructions}
407411
disabled={updateLoop.isPending}
408412
aria-label="Loop instructions"
409-
className="min-h-[200px] bg-(--color-panel-solid) text-[12.5px] leading-relaxed"
413+
className="max-h-[400px] min-h-[200px] bg-(--color-panel-solid) text-[12.5px] leading-relaxed"
410414
onChange={(e) => setDraft(e.currentTarget.value)}
411415
onBlur={(e) => commit(e.currentTarget.value)}
412416
onKeyDown={(e) => {

packages/ui/src/features/loops/components/LoopRow.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ export function LoopRow({
2525
creatorLookupComplete?: boolean;
2626
}) {
2727
const description = loop.description.trim();
28-
const triggerLabel = loop.triggers.length === 1 ? "trigger" : "triggers";
29-
const triggerSummary =
30-
loop.triggers.length === 0
31-
? "No triggers configured"
32-
: `${loop.triggers.length} ${triggerLabel}`;
3328

3429
let creatorLabel: string | null = null;
3530
if (loop.visibility === "team" && creatorError) {
@@ -46,7 +41,7 @@ export function LoopRow({
4641
: "Created by a former organization member";
4742
}
4843

49-
const metadata = [triggerSummary];
44+
const metadata: string[] = [];
5045
const notificationDestinations = summarizeNotificationDestinations(
5146
loop.notifications,
5247
);
@@ -63,22 +58,24 @@ export function LoopRow({
6358
>
6459
<Flex align="center" gap="3" className="min-w-0">
6560
<RepeatIcon size={20} className="shrink-0 text-gray-11" />
66-
<Flex direction="column" className="min-w-0 gap-0.5">
61+
<Flex direction="column" gap="1" className="min-w-0">
6762
<Flex align="center" gap="2" className="min-w-0">
6863
<Text className="truncate font-medium text-[13px] text-gray-12">
6964
{loop.name}
7065
</Text>
7166
<Badge color={loopStatusColor(loop)}>{loopStatusLabel(loop)}</Badge>
7267
<Badge color="gray">{loop.visibility}</Badge>
7368
</Flex>
74-
<Text className="text-[12px] text-gray-11 leading-snug">
75-
{metadata.join(" · ")}
76-
</Text>
7769
{description ? (
78-
<Text className="truncate text-[12px] text-gray-10 leading-snug">
70+
<Text className="truncate text-[12px] text-gray-11 leading-snug">
7971
{description}
8072
</Text>
8173
) : null}
74+
{metadata.length > 0 ? (
75+
<Text className="mt-0.5 text-(--accent-11) text-[11px] leading-snug">
76+
{metadata.join(" · ")}
77+
</Text>
78+
) : null}
8279
</Flex>
8380
</Flex>
8481
<Flex align="center" gap="3" className="shrink-0">

packages/ui/src/features/loops/components/LoopsListView.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";
66
import { Button } from "@posthog/ui/primitives/Button";
77
import { navigateToNewLoop } from "@posthog/ui/router/navigationBridge";
88
import { Flex, Heading, Text } from "@radix-ui/themes";
9-
import { useMemo } from "react";
9+
import { useMemo, useState } from "react";
1010
import { useLoopLimits, useLoops } from "../hooks/useLoops";
1111
import { useLoopDraftStore } from "../loopDraftStore";
1212
import type { LoopTemplate } from "../loopTemplates";
@@ -24,6 +24,8 @@ function loopLimitReason(max: number): string {
2424

2525
const EMPTY_MEMBERS: UserBasic[] = [];
2626

27+
const SECTION_PREVIEW_COUNT = 5;
28+
2729
function startBlankLoop(): void {
2830
useLoopDraftStore.getState().setPrefill(null);
2931
navigateToNewLoop();
@@ -219,13 +221,16 @@ function LoopListSection({
219221
membersError?: boolean;
220222
membersComplete?: boolean;
221223
}) {
224+
const [expanded, setExpanded] = useState(false);
225+
const visibleLoops = expanded ? loops : loops.slice(0, SECTION_PREVIEW_COUNT);
226+
222227
return (
223228
<Flex direction="column" gap="3">
224229
<Text className="font-medium text-[12px] text-gray-10 uppercase tracking-wide">
225230
{title}
226231
</Text>
227232
<Flex direction="column" gap="2">
228-
{loops.map((loop) => (
233+
{visibleLoops.map((loop) => (
229234
<LoopRow
230235
key={loop.id}
231236
loop={loop}
@@ -236,6 +241,17 @@ function LoopListSection({
236241
/>
237242
))}
238243
</Flex>
244+
{loops.length > SECTION_PREVIEW_COUNT ? (
245+
<Button
246+
variant="ghost"
247+
color="gray"
248+
size="1"
249+
className="w-fit"
250+
onClick={() => setExpanded(!expanded)}
251+
>
252+
{expanded ? "Show fewer" : `Show all ${loops.length}`}
253+
</Button>
254+
) : null}
239255
</Flex>
240256
);
241257
}

0 commit comments

Comments
 (0)