Skip to content

Commit ce0357b

Browse files
committed
feat(desktop): show create affordance before typing in channel browser
The create row only appeared once you started typing, so on first open the modal read as search-only. Surface a generic 'Create a new channel' row from the moment the dialog opens (specializing to 'Create «query»' as you type), so it's clear you can browse OR create from the get-go. Still hidden on an exact name match to avoid offering a duplicate. Adds e2e coverage asserting the create row is visible on open before typing.
1 parent 8422dde commit ce0357b

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

‎desktop/src/features/channels/ui/ChannelBrowserDialog.tsx‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ export function ChannelBrowserDialog({
239239
// The pinned create row (Are.na style) appears for any non-empty query that
240240
// isn't already an exact channel name — covering both partial-match and
241241
// no-match cases, so a dedicated empty-state button would be redundant.
242-
const showCreateRow = canCreate && trimmedQuery.length > 0 && !hasExactMatch;
242+
// The create row is present from the moment the dialog opens (so it's clear
243+
// you can browse *or* create), then specializes to "Create «query»" as you
244+
// type. It only hides when the query is an exact match for an existing name
245+
// — creating a duplicate "#general" makes no sense.
246+
const showCreateRow = canCreate && !hasExactMatch;
243247

244248
const updateTabIndicator = React.useCallback(() => {
245249
const list = tabListRef.current;
@@ -630,6 +634,7 @@ function CreateChannelRow({
630634
onClick: () => void;
631635
query: string;
632636
}) {
637+
const hasQuery = query.length > 0;
633638
return (
634639
<button
635640
className="flex w-full items-center gap-3 rounded-xl border border-border/70 bg-muted/30 px-4 py-3 text-left transition-colors duration-150 ease-out hover:bg-muted/60 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
@@ -640,12 +645,18 @@ function CreateChannelRow({
640645
<span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary">
641646
<Plus className="h-4 w-4" />
642647
</span>
643-
<span className="min-w-0 text-sm">
644-
<span className="font-medium text-foreground">
645-
Create {entityLabel}{" "}
648+
{hasQuery ? (
649+
<span className="min-w-0 text-sm">
650+
<span className="font-medium text-foreground">
651+
Create {entityLabel}{" "}
652+
</span>
653+
<span className="font-semibold text-foreground">“{query}”</span>
646654
</span>
647-
<span className="font-semibold text-foreground">“{query}”</span>
648-
</span>
655+
) : (
656+
<span className="min-w-0 text-sm font-medium text-foreground">
657+
Create a new {entityLabel}
658+
</span>
659+
)}
649660
</button>
650661
);
651662
}

‎desktop/tests/e2e/channel-browser.spec.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ test("sidebar add-channel button opens the browser", async ({ page }) => {
170170
await expect(page.getByTestId("channel-browser-dialog")).toBeVisible();
171171
});
172172

173+
test("create affordance is visible on open before typing", async ({ page }) => {
174+
await page.goto("/");
175+
176+
await openChannelBrowser(page);
177+
178+
// The create row is present from the get-go so it's clear you can browse OR
179+
// create — not just after you start typing.
180+
const createRow = page.getByTestId("channel-browser-create-row");
181+
await expect(createRow).toBeVisible();
182+
await expect(createRow).toContainText("Create a new channel");
183+
});
184+
173185
test("typing a partial match surfaces a persistent create row", async ({
174186
page,
175187
}) => {

0 commit comments

Comments
 (0)