From 43949d7c557c918c1bc76533289fa16622a4efef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Ign=C3=A1cio=20Fontoura=20Solla?= Date: Thu, 6 Aug 2026 01:25:18 -0300 Subject: [PATCH] revert: remove useCallback wrappers that caused performance regression --- .../campaign/shared/CampaignInfiniteTable.tsx | 17 ++++++----------- tests/e2e/campaignLeaderships.e2e.spec.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/components/campaign/shared/CampaignInfiniteTable.tsx b/src/components/campaign/shared/CampaignInfiniteTable.tsx index cc5875f6..26ef138a 100644 --- a/src/components/campaign/shared/CampaignInfiniteTable.tsx +++ b/src/components/campaign/shared/CampaignInfiniteTable.tsx @@ -177,8 +177,6 @@ export const CampaignInfiniteTable = ({ const extra = appended.pages.flat().filter((row) => !seedKeys.has(rowKey(row))) return [...rows, ...extra] }, [rows, appended.pages, rowKey]) - const loadedRowsRef = useRef(loadedRows) - loadedRowsRef.current = loadedRows useEffect(() => { setScrollElement(rootRef.current?.closest(CAMPAIGN_CONTENT_SCROLL_SELECTOR) ?? null) @@ -256,16 +254,13 @@ export const CampaignInfiniteTable = ({ const virtualizer = useVirtualizer({ count: itemCount, - estimateSize: useCallback(() => ESTIMATED_ROW_HEIGHT, []), - getScrollElement: useCallback(() => scrollElement, [scrollElement]), + estimateSize: () => ESTIMATED_ROW_HEIGHT, + getScrollElement: () => scrollElement, overscan: 8, - getItemKey: useCallback( - (index: number) => { - const row = loadedRowsRef.current[index] - return row ? rowKey(row) : `skeleton-${index}` - }, - [rowKey], - ), + getItemKey: (index) => { + const row = loadedRows[index] + return row ? rowKey(row) : `skeleton-${index}` + }, }) const virtualItems = virtualizer.getVirtualItems() diff --git a/tests/e2e/campaignLeaderships.e2e.spec.ts b/tests/e2e/campaignLeaderships.e2e.spec.ts index 1a5e0871..efa38908 100644 --- a/tests/e2e/campaignLeaderships.e2e.spec.ts +++ b/tests/e2e/campaignLeaderships.e2e.spec.ts @@ -97,6 +97,14 @@ test.describe('campaign leaderships list', () => { name: 'Buscar município, território de identidade ou zona eleitoral', }) await search.fill(added.name) + // Diagnostic: check if the listbox is in the DOM + const listbox = page.locator('[role="listbox"]') + const listboxCount = await listbox.count() + console.log(`Listbox count after fill: ${listboxCount}`) + if (listboxCount > 0) { + const listboxHTML = await listbox.first().innerHTML() + console.log(`Listbox HTML: ${listboxHTML.substring(0, 500)}`) + } const suggestion = page .getByRole('option') .filter({ has: page.getByText(added.name, { exact: true }) })