Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/src/layouts/NavBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,22 @@ describe('NavBar', () => {
});
expect(navigate).toHaveBeenCalledWith('/plots?focus=search');
});

it('navigates to debug on 5 clicks and stays there on 6', async () => {
const user = userEvent.setup();
const { container } = render(<NavBar />);

// 5 clicks
for (let i = 0; i < 5; i++) {
await user.click(container.querySelector('a[href="/"]')!);
}
expect(navigate).toHaveBeenCalledWith('/debug');
navigate.mockClear();

// 1 more click (6 total) within the time window
await user.click(container.querySelector('a[href="/"]')!);

// should still navigate to debug, preventing default link to /
expect(navigate).toHaveBeenCalledWith('/debug');
});
});
2 changes: 0 additions & 2 deletions app/src/layouts/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ export function NavBar() {
}, DEBUG_CLICK_WINDOW_MS);
if (clickCountRef.current >= DEBUG_CLICK_COUNT) {
e.preventDefault();
clickCountRef.current = 0;
if (clickTimerRef.current) clearTimeout(clickTimerRef.current);
navigate(paths.debug);
}
},
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/navbar-debug-click-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- **NavBar debug rapid clicks.** Fixed an issue where clicking the logo a 6th time rapidly navigated to home instead of staying in debug. The counter no longer resets when reaching 5 clicks.
Loading