alexandrusoare commented on code in PR #41754:
URL: https://github.com/apache/superset/pull/41754#discussion_r3529602852


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTableChart.tsx:
##########
@@ -113,26 +114,55 @@ export default function TableChart<D extends DataRecord = 
DataRecord>(
     }
   }, [columns]);
 
+  // A single effect owns every ownState write derived from render state.
+  // updateTableOwnState replaces ownState wholesale, so separate effects that
+  // each spread serverPaginationData in the same render would clobber one
+  // another's keys: clamping the current page, priming the raw-mode summary
+  // columns and nudging a re-query for missing totals must be one combined
+  // delta.
   useEffect(() => {
-    if (!serverPagination || !serverPaginationData || !rowCount) return;
+    const nextOwnState = { ...serverPaginationData };
+    let changed = false;
+
+    if (serverPagination && serverPaginationData && rowCount) {
+      const currentPage = serverPaginationData.currentPage ?? 0;
+      const currentPageSize = serverPaginationData.pageSize ?? 
serverPageLength;
+      const totalPages = Math.ceil(rowCount / currentPageSize);
+      if (currentPage >= totalPages && totalPages > 0) {
+        nextOwnState.currentPage = Math.max(0, totalPages - 1);
+        changed = true;

Review Comment:
   What do you think of this?



##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts:
##########
@@ -624,11 +624,19 @@ const buildQuery: BuildQuery<TableChartFormData> = (
 
     // Create totals query AFTER all filters (including AG Grid filters) are 
applied
     // This ensures we can properly exclude AG Grid WHERE filters from the 
totals
-    if (
+    // In raw records mode the summary is a SUM over the numeric columns primed
+    // into ownState by the chart (see rawSummaryColumns in transformProps).
+    const rawSummaryColumns =
+      queryMode === QueryMode.Raw && formData.show_totals
+        ? ensureIsArray(ownState.rawSummaryColumns as string[] | undefined)
+        : [];

Review Comment:
   This seems relevant



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to