fix: improve portfolio and image upload UX
- Fix tag suggestion dropdown positioning to appear below input (not overlay) - Limit tag suggestions to 4 for cleaner UI - Add separate X clear button for search tags (distinct from filter clear) - Ensure img URL parameter is cleared when closing image modal
This commit is contained in:
@@ -275,6 +275,20 @@
|
||||
|
||||
function clearFilters() {
|
||||
selectedFilters = {};
|
||||
offset = 0;
|
||||
|
||||
// Build URL with reactive page state
|
||||
const url = new URL(page.url);
|
||||
const keysToDelete = Array.from(url.searchParams.keys()).filter((k) => k.startsWith('filter['));
|
||||
keysToDelete.forEach((k) => url.searchParams.delete(k));
|
||||
// eslint-disable-next-line svelte/no-navigation-without-resolve
|
||||
goto(url.pathname + url.search, { replaceState: true, noScroll: true });
|
||||
|
||||
fetchImages(false);
|
||||
fetchFilters();
|
||||
}
|
||||
|
||||
function clearSearch() {
|
||||
selectedTag = '';
|
||||
selectedTags = [];
|
||||
searchQuery = '';
|
||||
@@ -284,13 +298,10 @@
|
||||
const url = new URL(page.url);
|
||||
url.searchParams.delete('tag');
|
||||
url.searchParams.delete('tags');
|
||||
const keysToDelete = Array.from(url.searchParams.keys()).filter((k) => k.startsWith('filter['));
|
||||
keysToDelete.forEach((k) => url.searchParams.delete(k));
|
||||
// eslint-disable-next-line svelte/no-navigation-without-resolve
|
||||
goto(url.pathname + url.search, { replaceState: true, noScroll: true });
|
||||
|
||||
fetchImages(false);
|
||||
fetchFilters();
|
||||
}
|
||||
|
||||
let sentinelRef: HTMLDivElement | undefined = $state(undefined);
|
||||
@@ -614,6 +625,27 @@
|
||||
<Button onclick={applySearch}>
|
||||
{loading ? 'Searching...' : 'Search'}
|
||||
</Button>
|
||||
|
||||
{#if selectedTag || selectedTags.length > 0}
|
||||
<button
|
||||
class="flex shrink-0 items-center justify-center"
|
||||
onclick={clearSearch}
|
||||
aria-label="Clear search tags"
|
||||
>
|
||||
<div
|
||||
class="flex h-6 w-6 items-center justify-center rounded-full bg-red-100 text-red-600 hover:bg-red-200"
|
||||
>
|
||||
<svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M6 18L18 6M6 6l12 12"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user