fix(FN-1207): improve mobile header search behavior

- Replace delayed focus effect with native autoFocus on the mobile search input
- Constrain expanded mobile search positioning and width to prevent overflow on small viewports
- Add Header tests covering mobile search auto-focus and expanded container rendering
This commit is contained in:
gsxdsm
2026-04-08 15:41:18 -07:00
parent d66300c794
commit 0304a3df20
3 changed files with 42 additions and 10 deletions

View File

@@ -459,6 +459,44 @@ describe("Header", () => {
expect(screen.getByPlaceholderText("Search tasks...")).toBeDefined();
});
it("focuses mobile search input when expanded", async () => {
const onSearchChange = vi.fn();
render(
<Header
view="board"
onChangeView={vi.fn()}
searchQuery=""
onSearchChange={onSearchChange}
/>
);
fireEvent.click(screen.getByTitle("Open search"));
const input = screen.getByPlaceholderText("Search tasks...") as HTMLInputElement;
await waitFor(() => {
expect(document.activeElement).toBe(input);
});
});
it("renders expanded mobile search container with expected class", () => {
const onSearchChange = vi.fn();
render(
<Header
view="board"
onChangeView={vi.fn()}
searchQuery=""
onSearchChange={onSearchChange}
/>
);
fireEvent.click(screen.getByTitle("Open search"));
const input = screen.getByPlaceholderText("Search tasks...");
const expandedContainer = input.closest(".mobile-search-expanded");
expect(expandedContainer).not.toBeNull();
expect(expandedContainer?.className).toContain("mobile-search-expanded");
});
it("mobile search stays expanded when searchQuery is non-empty", () => {
const onSearchChange = vi.fn();
render(