Add MapPage pagination and page-size selector; update Web-Design docs

This commit is contained in:
2026-03-29 15:23:47 +02:00
parent ccfcbc82c5
commit 7789353690
4 changed files with 180 additions and 45 deletions

View File

@@ -8,16 +8,26 @@ Reference: `Docs/Refactoring.md` for full analysis of each issue.
## Open Issues
- **World Map highlight does not reset on mouse leave** (done)
- Location: `frontend/src/components/WorldMap.tsx`, `GeoLayer` component
- Root cause: interactive event handlers (`onMouseEnter`, `onMouseMove`, `onMouseLeave`, `onClick`, `onKeyDown`) were on wrapping `<g>` element, creating mismatch with `Geography` internal hover state.
- Fix applied:
1. Interactive props and aria attributes are on `<Geography>`.
2. Hover highlight uses `style.hover` with derived `fill` from `isSelected/count`.
3. Tooltip state resets via `Geography.onMouseLeave` -> `setTooltip(null)`.
4. Test asserts tooltip appears/disappears and button role label is correct.
- Verification commands:
- `cd frontend && npx vitest --run src/components/__tests__/WorldMap.test.tsx`
- `cd frontend && npx vitest --run`
### Worldmap list pagination (new)
- Status: done
- Goal: Add paging controls to the WorldMap companion bans table (map page) so it matches Dashboard ban-list behavior and supports country drilldown without rendering / scrolling huge result sets.
- Implement in `frontend/src/pages/MapPage.tsx` using the dashboard pattern from `frontend/src/components/BanTable.tsx`:
1. Add local state: `page` (start 1), `pageSize` (e.g., 100).
2. Derive `visibleBans` from `useMemo` + `selectedCountry`, then compute `pageBans` using `slice((page-1)*pageSize, page*pageSize)`.
3. Compute `totalPages = Math.max(1, Math.ceil(visibleBans.length / pageSize))`, `hasPrev`, `hasNext`.
4. Render a footer row below Table with total, page, prev/next buttons (use icons `ChevronLeftRegular`, `ChevronRightRegular`, or existing style).
5. Wire buttons to `setPage(page - 1)` / `setPage(page + 1)`, disabled by bounds.
6. Reset `page` to 1 whenever `visibleBans` filter changes: on `range`, `originFilter`, `selectedCountry`, or when data refreshes.
- UX details:
- Keep existing “no bans found” row behavior.
- Keep summary info bar and total line consistent; show current slice counts in message as needed.
- Ensure paged data is used for `TableBody` mapping.
- Optional follow-ups:
- Allow page-size selector if needed (25/50/100), updating `totalPages` and reset to page 1 on change.
- Add tests in `frontend/src/pages/__tests__/MapPage.test.tsx` for paging behavior (initial page, next/prev, filtering reset).
- Add documentation in `Docs/Web-Design.md` if there is a worldmap data table UI guideline.