fix(managers): address the E4 S3 code-review round 3 findings
- The tag menu's "trigger is gone" test now measures against the SCROLLER, not the window. The page scroller starts ~230px down (measured), so a row that slid under the fixed toolbar was still "on screen" by window coords and the menu floated over the chrome, anchored to something invisible. - Scroll-repositioning keeps whichever side the menu is anchored to instead of resetting it to "below" every frame — that reset made the layout effect flip it back, costing two renders and two forced layouts per frame near the bottom edge. - One placement rule (`coordsFrom`) now serves the initial open, the layout correction and every reposition, so those can no longer drift apart. - Card page: reset on the filter/sort INPUTS only, and separately COMMIT the clamp when the page falls out of range. Keying the reset on the row count (round 2) was too blunt — a background refetch that merely added a channel threw the reader off page 7 for something they didn't do. - Pager derives `pageCount()` once and `hasPagerContent` reuses it, instead of the same expression twice in one file. - Re-indent the pagerNode JSX left dangling by round 2's ternary edit.
This commit is contained in:
@@ -7,12 +7,16 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||
// size and slices its own rows; this only renders the controls and reports changes. `sizeLabel` lets
|
||||
// the caller say "Rows per page" or "Cards per page". Returns null when there's nothing to page.
|
||||
|
||||
/** How many pages `total` rows make at `size` (`size <= 0` = "All" = one page). */
|
||||
function pageCount(total: number, size: number): number {
|
||||
return size <= 0 ? 1 : Math.max(1, Math.ceil(total / size));
|
||||
}
|
||||
|
||||
/** Whether a pager would render anything — the ONE owner of that rule. Callers that wrap the pager
|
||||
* in their own chrome gate on this instead of re-deriving it: a drifted second copy is exactly what
|
||||
* left empty control bands behind on tables with nothing to page. */
|
||||
export function hasPagerContent(total: number, size: number): boolean {
|
||||
const totalPages = size <= 0 ? 1 : Math.max(1, Math.ceil(total / size));
|
||||
return totalPages > 1 || total > 0;
|
||||
return pageCount(total, size) > 1 || total > 0;
|
||||
}
|
||||
export default function Pager({
|
||||
page,
|
||||
@@ -35,8 +39,7 @@ export default function Pager({
|
||||
sizeLabel: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const allRows = size <= 0;
|
||||
const totalPages = allRows ? 1 : Math.max(1, Math.ceil(total / size));
|
||||
const totalPages = pageCount(total, size);
|
||||
const safePage = Math.min(page, totalPages - 1);
|
||||
|
||||
// Local text for the editable "jump to page" box (committed on Enter/blur).
|
||||
|
||||
Reference in New Issue
Block a user