fix: search logic
This commit is contained in:
@@ -41,17 +41,15 @@
|
|||||||
<Command.Root>
|
<Command.Root>
|
||||||
<Command.Input bind:value={search} placeholder="Search topic..." />
|
<Command.Input bind:value={search} placeholder="Search topic..." />
|
||||||
<Command.List>
|
<Command.List>
|
||||||
<Command.Empty
|
<Command.Empty>
|
||||||
>{#if search && !data.topics.filter((t) => t.name?.includes(search)).length}
|
<form method="post" action="?/createTopic">
|
||||||
<form method="post" action="?/createTopic">
|
<input type="hidden" name="name" value={search} />
|
||||||
<input type="hidden" name="name" value={search} />
|
<button class="px-4 py-2 rounded bg-secondary">Add Topic</button>
|
||||||
<button class="px-4 py-2 rounded bg-secondary">Add Topic</button>
|
</form>
|
||||||
</form>
|
</Command.Empty>
|
||||||
{:else}No topic found.
|
|
||||||
{/if}</Command.Empty
|
|
||||||
>
|
|
||||||
<Command.Group>
|
<Command.Group>
|
||||||
{#each data.topics.filter((t) => !search || t.name?.includes(search)) as topic}
|
{#each data.topics as topic}
|
||||||
<form
|
<form
|
||||||
action="?/addTopic"
|
action="?/addTopic"
|
||||||
method="post"
|
method="post"
|
||||||
@@ -60,8 +58,8 @@
|
|||||||
>
|
>
|
||||||
<input type="hidden" name="topic-id" value={topic.id} />
|
<input type="hidden" name="topic-id" value={topic.id} />
|
||||||
<Command.Item
|
<Command.Item
|
||||||
value={topic.id.toString()}
|
value={topic.name!}
|
||||||
onSelect={async () => {
|
onSelect={() => {
|
||||||
addTopicForms[topic.id].submit();
|
addTopicForms[topic.id].submit();
|
||||||
closeAndFocusTrigger();
|
closeAndFocusTrigger();
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user