Skip to content

Commit cc5f9be

Browse files
mpstatonclaude
andcommitted
fix(org-workbench, organizations): create form seeds from the search box
The operator searches "New America", finds nothing, hits ➕ — and was asked to type the name again. OrgSearch now surfaces its query upward; OrgCreateInline seeds its name field from it, captured once at open so further typing in search doesn't clobber a form in progress. Follow-up to #29. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UvYzx7vDWeafnkAi2nEQeb
1 parent bcb0ecf commit cc5f9be

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

apps/org-workbench/src/App.svelte

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
}
4646
4747
// Gated org creation (issue #29) — the ➕ opens OrgCreateInline; both a
48-
// picked candidate and a fresh create land in the same loadOrg.
48+
// picked candidate and a fresh create land in the same loadOrg. The form
49+
// seeds from whatever was searched — no-results is the create path.
4950
let creating = $state(false);
51+
let searchQuery = $state('');
5052
5153
function onCreateOpen(org_slug: string) {
5254
creating = false;
@@ -110,7 +112,7 @@
110112
<span class="ow-ws status-{status}">{status}</span>
111113
</div>
112114
<div class="ow-search-row">
113-
<OrgSearch {client} onpick={onPick} />
115+
<OrgSearch {client} onpick={onPick} onquery={(q) => (searchQuery = q)} />
114116
<button
115117
type="button"
116118
class="ow-add-go"
@@ -121,7 +123,12 @@
121123
</button>
122124
</div>
123125
{#if creating}
124-
<OrgCreateInline {client} onopen={onCreateOpen} oncancel={() => (creating = false)} />
126+
<OrgCreateInline
127+
{client}
128+
initialName={searchQuery}
129+
onopen={onCreateOpen}
130+
oncancel={() => (creating = false)}
131+
/>
125132
{/if}
126133
</header>
127134

apps/org-workbench/src/OrgCreateInline.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@
1414
1515
let {
1616
client,
17+
initialName = '',
1718
onopen,
1819
oncancel,
1920
}: {
2021
client: string;
22+
// Seeds the name field from the search box — the operator already typed
23+
// the org they couldn't find; don't make them type it twice.
24+
initialName?: string;
2125
// Called with the slug to load — an existing candidate OR the new org.
2226
onopen: (org_slug: string) => void;
2327
oncancel: () => void;
2428
} = $props();
2529
26-
let name = $state('');
30+
// Seed-once by design: the form captures what was searched at open;
31+
// continuing to type in the search box must not clobber a form in progress.
32+
// svelte-ignore state_referenced_locally
33+
let name = $state(initialName);
2734
let site = $state(''); // URL or bare domain, optional
2835
let phase = $state<'form' | 'gate' | 'writing'>('form');
2936
let candidates = $state<OrgCandidate[]>([]);

apps/org-workbench/src/OrgSearch.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
let {
1010
client,
1111
onpick,
12+
onquery,
1213
}: {
1314
client: string;
1415
onpick: (org: OrgSuggestion) => void;
16+
// Lets the parent seed the gated-create form with what was searched —
17+
// the no-results path usually IS the create path (issue #29 follow-up).
18+
onquery?: (q: string) => void;
1519
} = $props();
1620
1721
const DEBOUNCE_MS = 300;
@@ -26,6 +30,7 @@
2630
error = null;
2731
if (timer) clearTimeout(timer);
2832
const trimmed = q.trim();
33+
onquery?.(trimmed);
2934
if (trimmed.length < 2) {
3035
suggestions = [];
3136
return;

0 commit comments

Comments
 (0)