-
Notifications
You must be signed in to change notification settings - Fork 191
fix: broken clear search functionality #2405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
31f5a7e
6807249
2e951bf
2e6471d
9a47c1c
0b54321
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Creates a clear search function for SearchQuery components | ||
* @param searchQuery | ||
* @returns A function that clears the search input | ||
*/ | ||
export function createClearSearch(searchQuery: { clearInput?: () => void } | undefined) { | ||
return () => { | ||
searchQuery?.clearInput?.(); | ||
}; | ||
} | ||
|
||
/** | ||
* @param searchQuery | ||
*/ | ||
export function clearSearchInput(searchQuery: { clearInput?: () => void } | undefined) { | ||
searchQuery?.clearInput?.(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import { base } from '$app/paths'; | ||
import { page } from '$app/state'; | ||
import { EmptySearch, PaginationWithLimit, ViewSelector } from '$lib/components/index.js'; | ||
import { clearSearchInput } from '$lib/helpers/clearSearch'; | ||
import { Button } from '$lib/elements/forms'; | ||
import Link from '$lib/elements/link.svelte'; | ||
import { toLocaleDateTime } from '$lib/helpers/date'; | ||
|
@@ -39,6 +40,8 @@ | |
let showDelete = false; | ||
let showRetry = false; | ||
let selectedDomain: Models.Domain = null; | ||
let searchQuery; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, for type. |
||
const clearSearch = () => clearSearchInput(searchQuery); | ||
const isDomainVerified = (domain: Models.Domain) => { | ||
return domain.nameservers.toLowerCase() === 'appwrite'; | ||
|
@@ -47,7 +50,7 @@ | |
|
||
<Container> | ||
<Layout.Stack direction="row" justifyContent="space-between"> | ||
<SearchQuery placeholder="Search domains" /> | ||
<SearchQuery bind:this={searchQuery} placeholder="Search domains" /> | ||
<Layout.Stack direction="row" gap="m" inline> | ||
<ViewSelector ui="new" view={View.Table} {columns} hideView /> | ||
<Button | ||
|
@@ -183,6 +186,7 @@ | |
queries.clearAll(); | ||
queries.apply(); | ||
}}>Clear filters</Button> | ||
<Button secondary on:click={clearSearch}>Clear search</Button> | ||
</svelte:fragment> | ||
</EmptySearch> | ||
{:else} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,6 @@ | |
Tooltip | ||
} from '@appwrite.io/pink-svelte'; | ||
import SearchQuery from '$lib/components/searchQuery.svelte'; | ||
import { base } from '$app/paths'; | ||
import { page } from '$app/state'; | ||
import CertificateInfoModal from './certificateInfoModal.svelte'; | ||
import DeleteCertificateModal from './deleteCertificateModal.svelte'; | ||
|
@@ -26,13 +24,18 @@ | |
let showDelete = false; | ||
let showAdvancedInfo = false; | ||
let selectedCertificate = null; //TODO: add type | ||
let searchQuery; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whats the type? |
||
function clearSearch() { | ||
searchQuery?.clearInput(); | ||
} | ||
const now = new Date(); | ||
</script> | ||
|
||
<Container> | ||
<Layout.Stack direction="row" justifyContent="space-between"> | ||
<SearchQuery placeholder="Search by ID" /> | ||
<SearchQuery bind:this={searchQuery} placeholder="Search by ID" /> | ||
</Layout.Stack> | ||
|
||
{#if data.certificates.total} | ||
|
@@ -138,13 +141,9 @@ | |
offset={data.offset} | ||
total={data.certificates.total} /> | ||
{:else if data?.search} | ||
<EmptySearch hidePages bind:search={data.search} target="certificates"> | ||
<EmptySearch hidePages search={data.search} target="certificates"> | ||
<svelte:fragment slot="actions"> | ||
<Button | ||
secondary | ||
href={`${base}/organization-${page.params.organization}/domains/domain-${page.params.domain}/certificates`}> | ||
Clear search | ||
</Button> | ||
<Button secondary on:click={clearSearch}>Clear search</Button> | ||
</svelte:fragment> | ||
</EmptySearch> | ||
{:else} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,14 @@ | |
import { Icon } from '@appwrite.io/pink-svelte'; | ||
import { IconPlus } from '@appwrite.io/pink-icons-svelte'; | ||
import EmptySearch from '$lib/components/emptySearch.svelte'; | ||
import { clearSearchInput } from '$lib/helpers/clearSearch'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainGood: Centralized clear helper Importing Run the following to confirm the helper clears even when the instance is undefined (e.g., updates URL/search params): 🏁 Script executed: #!/bin/bash
# Inspect helper implementation for fallback behavior
echo "== helper source =="
sed -n '1,200p' src/lib/helpers/clearSearch.ts || true
echo
echo "== look for fallbacks =="
rg -n -C2 -g 'src/lib/helpers/clearSearch.ts' -e 'goto|URLSearchParams|setSearchParams|history|location|clearInput' Length of output: 1265 Add fallback in clearSearchInput for undefined searchQuery 🤖 Prompt for AI Agents
|
||
export let data: PageData; | ||
let showCreate = false; | ||
const project = page.params.project; | ||
let searchQuery: { clearInput: () => void } | undefined; | ||
const clearSearch = () => clearSearchInput(searchQuery); | ||
async function handleCreate(event: CustomEvent<Models.Database>) { | ||
showCreate = false; | ||
|
@@ -50,7 +53,8 @@ | |
hasSearch | ||
{columns} | ||
bind:view={data.view} | ||
searchPlaceholder="Search by name or ID"> | ||
searchPlaceholder="Search by name or ID" | ||
bind:searchQuery> | ||
{#if $canWriteDatabases} | ||
<Button event="create_database" on:click={() => (showCreate = true)}> | ||
<Icon icon={IconPlus} slot="start" size="s" /> | ||
|
@@ -73,10 +77,7 @@ | |
total={data.databases.total} /> | ||
{:else if data.search} | ||
<EmptySearch target="databases" hidePagination> | ||
<Button | ||
href={`${base}/project-${page.params.region}-${page.params.project}/databases`} | ||
size="s" | ||
secondary>Clear Search</Button> | ||
<Button on:click={clearSearch} size="s" secondary>Clear Search</Button> | ||
</EmptySearch> | ||
{:else} | ||
<Empty | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should avoid this pattern. we have many search inputs and creating a binding instance is not the best DX. we should be somehow able to listen to the changes for clear button and clear queries. We already also have below for queries -
not sure if it supports search as well.