From 681e2546f0784e82b899a4a080edc83f7f26ac97 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 31 Oct 2026 20:26:34 +0100 Subject: [PATCH] fix: lay the global search sheet out from the top --- .../__tests__/global-search-layout.test.ts | 30 +++++++++++++++++++ src/components/search/GlobalSearchSheet.tsx | 12 +++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/components/__tests__/global-search-layout.test.ts diff --git a/src/components/__tests__/global-search-layout.test.ts b/src/components/__tests__/global-search-layout.test.ts new file mode 100644 index 00000000..d173d0f5 --- /dev/null +++ b/src/components/__tests__/global-search-layout.test.ts @@ -0,0 +1,30 @@ +// The global search sheet put its type chips mid-screen, with empty bands +// above and below, and started the results at about 60% of the height: the +// chips' horizontal ScrollView grew like flex: 1 in the sheet's column. +import { describe, expect, it } from 'vitest'; +import fs from 'node:fs'; +import path from 'node:path'; + +const src = fs.readFileSync(path.resolve(__dirname, '../search/GlobalSearchSheet.tsx'), 'utf8'); + +function styleBody(name: string): string { + const m = new RegExp(`\\n\\s+${name}: \\{([^}]*)\\}`).exec(src); + expect(m, `style ${name}`).not.toBeNull(); + return m![1]; +} + +describe('global search sheet layout', () => { + it('keeps the chip row to its own height', () => { + const scroll = //.exec(src); + expect(scroll).not.toBeNull(); + const style = /\sstyle=\{styles\.(\w+)\}/.exec(scroll![1]); + expect(style, 'the horizontal ScrollView needs its own style').not.toBeNull(); + const body = styleBody(style![1]); + expect(body).toMatch(/flexGrow: 0/); + expect(body).toMatch(/flexShrink: 0/); + }); + + it('gives the rest of the sheet to the results', () => { + expect(styleBody('results')).toMatch(/flex: 1/); + }); +}); diff --git a/src/components/search/GlobalSearchSheet.tsx b/src/components/search/GlobalSearchSheet.tsx index b8c0849e..df82fcd0 100644 --- a/src/components/search/GlobalSearchSheet.tsx +++ b/src/components/search/GlobalSearchSheet.tsx @@ -245,7 +245,16 @@ export function GlobalSearchSheet({ visible, initialQuery = '', onClose, navigat - + {/* Its own height only: a horizontal ScrollView grows like flex: 1 + in a column, which put the chips mid-screen with empty bands + above and below and pushed the results down. */} + {scopes.map((s) => chip(s.key, s.label, scope === s.key, () => setScope(s.key)))} {accounts.length > 1 ? ( <> @@ -309,6 +318,7 @@ function makeStyles(c: ThemePalette) { borderWidth: 1, borderColor: c.border, }, input: { flex: 1, ...typography.body, color: c.text, paddingVertical: spacing.sm }, + chipsScroll: { flexGrow: 0, flexShrink: 0 }, chips: { flexDirection: 'row', alignItems: 'center', gap: spacing.xs, paddingHorizontal: spacing.md, paddingVertical: spacing.sm }, chip: { paddingHorizontal: spacing.md, paddingVertical: 6, borderRadius: radius.full,