fix(search): tagQ alone now triggers search mode; selecting chip clears tagQ
- isDashboard was ignoring tagQ so typing in tag filter showed dashboard
- addTag now calls onTextInput('') to clear tagQ when a chip is selected
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ export async function load({ url, fetch }) {
|
||||
const dir = url.searchParams.get('dir') || 'desc';
|
||||
const tagQ = url.searchParams.get('tagQ') || '';
|
||||
|
||||
const isDashboard = !q && !from && !to && !senderId && !receiverId && !tags.length;
|
||||
const isDashboard = !q && !from && !to && !senderId && !receiverId && !tags.length && !tagQ;
|
||||
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
|
||||
@@ -167,6 +167,27 @@ describe('home page load — search mode', () => {
|
||||
expect(firstCall[1].params.query.q).toBe('Urlaub');
|
||||
expect(firstCall[1].params.query.from).toBe('2020-01-01');
|
||||
});
|
||||
|
||||
it('sets isDashboard false when only tagQ is set', async () => {
|
||||
const mockGet = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
response: { ok: true, status: 200 },
|
||||
data: { documents: [{ id: 'd1' }], total: 1 }
|
||||
}) // search docs
|
||||
.mockResolvedValueOnce({ response: { ok: true, status: 200 }, data: [] }); // persons
|
||||
vi.mocked(createApiClient).mockReturnValue({ GET: mockGet } as ReturnType<
|
||||
typeof createApiClient
|
||||
>);
|
||||
|
||||
const result = await load({
|
||||
url: makeUrl({ tagQ: 'fam' }),
|
||||
fetch: vi.fn() as unknown as typeof fetch
|
||||
});
|
||||
|
||||
expect(result.isDashboard).toBe(false);
|
||||
expect(result.documents).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('passes sort, dir, and tagQ params to the documents API', async () => {
|
||||
|
||||
Reference in New Issue
Block a user