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:
@@ -44,6 +44,7 @@ function addTag(tag: string) {
|
||||
suggestions = [];
|
||||
showSuggestions = false;
|
||||
activeIndex = -1;
|
||||
onTextInput?.('');
|
||||
}
|
||||
|
||||
function removeTag(index: number) {
|
||||
|
||||
@@ -228,4 +228,16 @@ describe('TagInput – onTextInput callback', () => {
|
||||
const input = page.getByRole('textbox');
|
||||
await expect(input.fill('fa')).resolves.not.toThrow();
|
||||
});
|
||||
|
||||
it('calls onTextInput with empty string when a tag chip is added', async () => {
|
||||
mockFetchWithTags(['Kaufvertrag']);
|
||||
const onTextInput = vi.fn();
|
||||
render(TagInput, { tags: [], allowCreation: false, onTextInput });
|
||||
const input = page.getByRole('textbox');
|
||||
await input.fill('Ka');
|
||||
await waitForDebounce();
|
||||
const option = page.getByRole('option', { name: 'Kaufvertrag' });
|
||||
await option.click();
|
||||
await expect.poll(() => onTextInput.mock.calls.at(-1)).toEqual(['']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user