Keep list search usable in narrow windows

The patch and issue list topbars decided whether to show filter labels
from the viewport width, which ignores the sidebar. With the search
input open, the filters left it almost no room, and in narrower
windows the actions were pushed past the window edge.

Make the topbar a size container and show filter labels based on its
own width. While searching, collapse inactive filters to icons and give
the input a fixed width. When there is still not enough room, the
filters scroll and fade out at the clipped edge.

Fixes: 0d6def4600
This commit is contained in:
Brandon Oxendine
2026-10-20 13:34:00 +02:00
committed by Rūdolfs Ošiņš
parent 2fd961c6c3
commit 7dd1ad2e55
4 changed files with 150 additions and 62 deletions
+1
View File
@@ -19,6 +19,7 @@
border-bottom: 1px solid var(--color-border-subtle);
font: var(--txt-body-m-regular);
color: var(--color-text-secondary);
container-type: inline-size;
}
</style>
+29
View File
@@ -0,0 +1,29 @@
const fadeWidth = "3rem";
export function overflowFade(node: HTMLElement) {
function update() {
const start = node.scrollLeft > 0;
const end = node.scrollLeft + node.clientWidth < node.scrollWidth - 1;
const mask =
start || end
? `linear-gradient(to right, ${start ? "transparent" : "black"} 0, black ${start ? fadeWidth : "0"}, black calc(100% - ${end ? fadeWidth : "0px"}), ${end ? "transparent" : "black"} 100%)`
: "";
node.style.maskImage = mask;
node.style.webkitMaskImage = mask;
}
const observer = new ResizeObserver(update);
observer.observe(node);
for (const child of node.children) {
observer.observe(child);
}
node.addEventListener("scroll", update, { passive: true });
update();
return {
destroy() {
observer.disconnect();
node.removeEventListener("scroll", update);
},
};
}
+63 -32
View File
@@ -17,6 +17,7 @@
updateIssueCounts,
} from "@app/lib/issueCounts.svelte";
import { show } from "@app/lib/modal";
import { overflowFade } from "@app/lib/overflowFade";
import { createPaginatedList } from "@app/lib/paginatedList.svelte";
import * as router from "@app/lib/router";
import { modifierKey } from "@app/lib/utils";
@@ -135,6 +136,9 @@
display: flex;
align-items: center;
gap: 0.25rem;
min-width: 0;
overflow-x: auto;
scrollbar-width: none;
}
.filter {
display: flex;
@@ -158,6 +162,27 @@
.filter .global-counter-badge {
margin-left: 0.25rem;
}
.filters.compact .filter:not(.active) .filter-label {
display: none;
}
.actions {
display: flex;
align-items: center;
gap: 0.5rem;
margin-left: auto;
flex-shrink: 0;
}
.search {
display: flex;
}
.search.expanded {
width: 16rem;
}
@container (max-width: 40rem) {
.search.expanded {
width: 10rem;
}
}
.row {
border-bottom: 1px solid var(--color-border-subtle);
}
@@ -167,7 +192,7 @@
<div class="page">
<Topbar>
<span class="topbar-title">Issues</span>
<div class="filters">
<div class="filters" class:compact={showSearch} use:overflowFade>
<a
class="filter"
class:active={status === "all"}
@@ -176,7 +201,8 @@
rid: repo.rid,
status: "all",
})}>
<Icon name="issue" />All
<Icon name="issue" />
<span class="filter-label">All</span>
<span class="global-counter-badge">
{project.meta.issues.open + project.meta.issues.closed}
</span>
@@ -189,7 +215,8 @@
rid: repo.rid,
status: "open",
})}>
<Icon name="issue" />Open
<Icon name="issue" />
<span class="filter-label">Open</span>
<span class="global-counter-badge">{project.meta.issues.open}</span>
</a>
<a
@@ -200,37 +227,40 @@
rid: repo.rid,
status: "closed",
})}>
<Icon name="issue-closed" />Closed
<Icon name="issue-closed" />
<span class="filter-label">Closed</span>
<span class="global-counter-badge">{project.meta.issues.closed}</span>
</a>
</div>
<div class="global-flex" style:margin-left="auto" style:gap="0.5rem">
<FuzzySearch
hasItems={list.items.length > 0}
placeholder={`Search issues ${modifierKey()} + f`}
icon={loading ? "clock" : "search"}
onFocus={async () => {
try {
loading = true;
await list.loadMore(true);
} catch (e) {
console.error("Loading all issues failed: ", e);
} finally {
loading = false;
}
}}
onSubmit={async () => {
if (searchResults.length === 1) {
await router.push({
resource: "repo.issue",
rid: repo.rid,
issue: searchResults[0].id,
status,
});
}
}}
bind:show={showSearch}
bind:value={searchInput} />
<div class="actions">
<div class="search" class:expanded={showSearch}>
<FuzzySearch
hasItems={list.items.length > 0}
placeholder={`Search issues ${modifierKey()} + f`}
icon={loading ? "clock" : "search"}
onFocus={async () => {
try {
loading = true;
await list.loadMore(true);
} catch (e) {
console.error("Loading all issues failed: ", e);
} finally {
loading = false;
}
}}
onSubmit={async () => {
if (searchResults.length === 1) {
await router.push({
resource: "repo.issue",
rid: repo.rid,
issue: searchResults[0].id,
status,
});
}
}}
bind:show={showSearch}
bind:value={searchInput} />
</div>
<Button
styleHeight="2rem"
variant="secondary"
@@ -239,7 +269,8 @@
component: CreateIssueModal,
props: { repo },
})}>
<Icon name="plus" />New issue
<Icon name="plus" />
<span class="global-hide-on-small-desktop-down">New issue</span>
</Button>
</div>
</Topbar>
+57 -30
View File
@@ -11,6 +11,7 @@
import { searchCobs } from "@app/lib/cobSearch";
import { debounced } from "@app/lib/debounced.svelte";
import { channel, invoke } from "@app/lib/invoke";
import { overflowFade } from "@app/lib/overflowFade";
import { createPaginatedList } from "@app/lib/paginatedList.svelte";
import {
patchCountMismatch,
@@ -126,6 +127,9 @@
display: flex;
align-items: center;
gap: 0.25rem;
min-width: 0;
overflow-x: auto;
scrollbar-width: none;
}
.filter {
display: flex;
@@ -155,11 +159,32 @@
.filter.active .filter-label {
display: inline;
}
@media (min-width: 1011px) {
@container (min-width: 54rem) {
.filter-label {
display: inline;
}
}
.filters.compact .filter:not(.active) .filter-label {
display: none;
}
.actions {
display: flex;
align-items: center;
gap: 0.5rem;
margin-left: auto;
flex-shrink: 0;
}
.search {
display: flex;
}
.search.expanded {
width: 16rem;
}
@container (max-width: 54rem) {
.search.expanded {
width: 10rem;
}
}
.row {
border-bottom: 1px solid var(--color-border-subtle);
}
@@ -169,7 +194,7 @@
<div class="page">
<Topbar>
<span class="topbar-title">Patches</span>
<div class="filters">
<div class="filters" class:compact={showSearch} use:overflowFade>
<a
class="filter"
class:active={status === undefined}
@@ -240,34 +265,36 @@
<span class="global-counter-badge">{project.meta.patches.draft}</span>
</a>
</div>
<div class="global-flex" style:margin-left="auto" style:gap="0.5rem">
<FuzzySearch
hasItems={list.items.length > 0}
placeholder={`Search patches ${modifierKey()} + f`}
icon={loading ? "clock" : "search"}
onFocus={async () => {
try {
loading = true;
await list.loadMore(true);
} catch (e) {
console.error("Loading all patches failed: ", e);
} finally {
loading = false;
}
}}
onSubmit={async () => {
if (searchResults.length === 1) {
await router.push({
patch: searchResults[0].id,
resource: "repo.patch",
reviewId: undefined,
rid: repo.rid,
status,
});
}
}}
bind:show={showSearch}
bind:value={searchInput} />
<div class="actions">
<div class="search" class:expanded={showSearch}>
<FuzzySearch
hasItems={list.items.length > 0}
placeholder={`Search patches ${modifierKey()} + f`}
icon={loading ? "clock" : "search"}
onFocus={async () => {
try {
loading = true;
await list.loadMore(true);
} catch (e) {
console.error("Loading all patches failed: ", e);
} finally {
loading = false;
}
}}
onSubmit={async () => {
if (searchResults.length === 1) {
await router.push({
patch: searchResults[0].id,
resource: "repo.patch",
reviewId: undefined,
rid: repo.rid,
status,
});
}
}}
bind:show={showSearch}
bind:value={searchInput} />
</div>
<NewPatchButton rid={repo.rid} />
</div>
</Topbar>