bito-code-review[bot] commented on code in PR #37555:
URL: https://github.com/apache/superset/pull/37555#discussion_r2843409594


##########
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:
   <!-- Bito Reply -->
   This change updates the pagination logic to use the filtered data length for 
totalItems, ensuring the table's pagination reflects only the visible 
(filtered) results. It also clamps the current page to a valid range based on 
the filtered data, preventing empty pages when filters reduce the dataset. This 
fixes a UX issue where users could end up on blank pages after filtering.
   
   
**superset-frontend/src/components/Datasource/components/CollectionTable/index.tsx**
   ```
   const totalItems = displayData.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,
               total: totalItems,
             };
   ```



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