Skip to content

fix: table is not scrolled to top on sorting #2347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 3, 2025
Merged

Conversation

astandrik
Copy link
Collaborator

@astandrik astandrik commented May 30, 2025

Closes #2345

Stand

Now on prod table is not scrolled to top on sorting at all
I suppose this to be severe bug

Here we scroll regular tables to top on sorting

Grouped tables on sorting scroll to top of specific group that is being sorted

Also on prod there is common sortParams for all tables (even if I sort only one group)

In this pr every group has independent sort params (as now every group has its own state)

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
318 317 0 1 0

😟 No changes in tests. 😕

Bundle Size: 🔺

Current: 83.65 MB | Main: 83.65 MB
Diff: +5.65 KB (0.01%)

⚠️ Bundle size increased. Please review.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that tables reset their scroll position to the top when a sort action occurs, and it gives each grouped/paginated table its own independent sort state.

  • Added an onSort callback to TableWithControlsLayout.Table that triggers scroll-to-top after sorting.
  • Updated container components (Tenants, TabletsTable, grouped storage/nodes components) to pass onSort and reset sort state per group.
  • Refactored PaginatedTableWithLayout to include sort parameters in its scroll dependencies for auto-scrolling.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/components/TableWithControlsLayout/TableWithControlsLayout.tsx Added onSort prop and wrapping logic in the Table.
src/containers/Tenants/Tenants.tsx Passed onSort through to the main table render.
src/containers/Tablets/TabletsTable.tsx Passed onSort into the data table.
src/containers/Storage/**/Grouped*Component.tsx Introduced PaginatedTableWithLayout with independent sort state per group.
src/containers/Nodes/PaginatedNodes/GroupedNodesComponent.tsx Same grouping changes for node tables.
src/components/PaginatedTable/PaginatedTableWithLayout.tsx Created TableWithAutoScrolling to wire sort state into scroll deps.
Comments suppressed due to low confidence (1)

src/components/TableWithControlsLayout/TableWithControlsLayout.tsx:74

  • No tests were added to verify that handleSort correctly invokes onSort and then scrolls the table. Consider adding a unit or integration test for this behavior.
const handleSort = React.useCallback(

artemmufazalov
artemmufazalov previously approved these changes Jun 2, 2025
@astandrik
Copy link
Collaborator Author

Actually I dont like current approach with onSort passing to table
Want to have one source of functionality that is scrollDependencies

will rework here

Copilot

This comment was marked as outdated.

@astandrik astandrik requested a review from artemmufazalov June 2, 2025 14:11
@astandrik
Copy link
Collaborator Author

stand redeployed

@astandrik
Copy link
Collaborator Author

@artemmufazalov check again please - removed children-function approach in favor of unified scrollDependencies approach

@@ -70,6 +70,9 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
);
const loading = isFetching && currentData === undefined;

// Track sort state for scroll dependencies
const [sortParams, setSortParams] = React.useState<any>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<SortOrder | SortOrder[] | undefined>?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@astandrik astandrik requested a review from artemmufazalov June 3, 2025 09:52
@astandrik astandrik added this pull request to the merge queue Jun 3, 2025
Merged via the queue into main with commit 7bde143 Jun 3, 2025
7 checks passed
@astandrik astandrik deleted the astandrik.2345 branch June 3, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: table is not scrolled to top on sorting
2 participants