madhushreeag commented on code in PR #37555:
URL: https://github.com/apache/superset/pull/37555#discussion_r2843405691


##########
superset-frontend/src/components/Datasource/components/CollectionTable/index.tsx:
##########
@@ -416,6 +448,21 @@ export default class CRUDCollection extends PureComponent<
         }
       : undefined;
 
+    // Build controlled pagination config, clamping currentPage to valid range
+    // when the collection shrinks (e.g. due to filtering/search)
+    const totalItems = this.state.collectionArray.length;
+    const pageSize = this.state.pageSize;
+    const maxPage = totalItems > 0 ? Math.ceil(totalItems / pageSize) : 1;
+    const currentPage = Math.min(this.state.currentPage, maxPage);
+    const paginationConfig: false | TablePaginationConfig | undefined =
+      pagination === false || pagination === undefined
+        ? pagination
+        : {
+            ...(typeof pagination === 'object' ? pagination : {}),
+            current: currentPage,
+            pageSize,
+          };

Review Comment:
    Changed totalItems from this.state.collectionArray.length to 
displayData.length so clamping is based on filtered results
    Added total: totalItems to paginationConfig so Ant Design Table knows the 
correct total for the filtered view
   



-- 
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