Skip to content

fix: paginated table in groups scrolled to top on refresh #2291

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 4 commits into from
May 22, 2025

Conversation

astandrik
Copy link
Collaborator

@astandrik astandrik commented May 16, 2025

Stand

Closes #2200

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.62 MB | Main: 83.59 MB
Diff: +0.04 MB (0.04%)

⚠️ 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.

@astandrik astandrik force-pushed the astandrik.2200 branch 2 times, most recently from 13bd573 to a5eb2ea Compare May 19, 2025 11:14
@astandrik astandrik marked this pull request as ready for review May 19, 2025 11:22
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 refactors paginated tables to use a scrollContainerRef instead of parentRef and introduces a context-based table state (PaginatedTableProvider) along with automatic scroll adjustment (useTableScroll). It also removes the old renderControls props and centralizes control rendering via context consumers.

  • Swap parentRef for scrollContainerRef across table components
  • Introduce PaginatedTableProvider and remove per-component control rendering
  • Add useTableScroll hook and update TableWithControlsLayout.Table for sticky scroll adjustments

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/containers/Storage/StorageNodes/getNodes.ts Added mock generation path via URL params
src/components/TableWithControlsLayout/useTableScroll.ts New hook to sync table and container scrolling
src/components/TableWithControlsLayout/TableWithControlsLayout.tsx Updated Table component to use useTableScroll and refs
src/components/PaginatedTable/ResizeablePaginatedTable.tsx Added onStateChange prop (unused)
src/components/PaginatedTable/PaginatedTable.tsx Removed parentRef and moved to context for scroll handling
Comments suppressed due to low confidence (1)

src/containers/Storage/StorageNodes/nodes.ts:25

  • [nitpick] The callback parameter Name starts with an uppercase letter and may be confused with a type or class. Rename it to name for consistency with JavaScript naming conventions.
    return poolNames.slice(0, count).map((Name) => ({

@astandrik astandrik requested a review from Copilot May 19, 2025 11:40
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 standardizes scrolling behavior by replacing parentRef with scrollContainerRef, introduces automatic table scrolling on updates, and refactors paginated table state to use a React context.

  • Replace all parentRef props with scrollContainerRef to unify scroll logic.
  • Add useTableScroll hook and extend TableWithControlsLayout for auto-scrolling and full-height support.
  • Refactor PaginatedTable to use a context provider for internal state, removing ad-hoc control rendering.

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/containers/Tablets/TabletsTable.tsx Enable full-height layout to support new scroll behavior
src/components/TableWithControlsLayout/useTableScroll.ts New hook to handle scrolling the table into view
src/components/TableWithControlsLayout/TableWithControlsLayout.tsx Extend layout with fullHeight, scrollContainerRef, and dependencies
src/components/PaginatedTable/types.ts Update types: rename parentRefscrollContainerRef, adjust render control signatures
src/components/PaginatedTable/PaginatedTableContext.tsx Introduce PaginatedTableProvider context for table state
src/components/PaginatedTable/useScrollBasedChunks.ts Rename hook prop to scrollContainerRef and update internal logic
src/components/PaginatedTable/PaginatedTable.tsx Refactor to use context, remove parentRef, and simplify rendering
various containers (Storage*, Nodes*, Cluster.tsx, etc.) Replace parentRef with scrollContainerRef in paginated/table components
Comments suppressed due to low confidence (3)

src/containers/Storage/StorageNodes/PaginatedStorageNodes.tsx:37

  • [nitpick] Multiple *ControlsWithTableState components across containers share identical patterns. Consider extracting a generic higher-order component to avoid duplication and ease future updates.
function StorageNodesControlsWithTableState({

src/components/PaginatedTable/PaginatedTable.tsx:131

  • The previous implementation scrolled the container to top on filter/reset via parentRef.current.scrollTo(0,0). With parentRef removed, the table no longer resets scroll position on filter changes; consider invoking scrollContainerRef.current.scrollTo(0, 0) after resetting state.
React.useLayoutEffect(() => {

src/components/TableWithControlsLayout/useTableScroll.ts:1

  • The new useTableScroll hook controls critical scroll behavior but lacks dedicated unit tests. Consider adding tests to verify scroll adjustment logic under different table positions and dependency changes.
import React from 'react';

@astandrik
Copy link
Collaborator Author

scrolls with small table leaves some extra pixels of cluster overview

@astandrik
Copy link
Collaborator Author

@Raubzeug moved pyramid to separate component
fixed scrolling for databases and tablets
fixed extra pixels issue

stand redeployed

@astandrik astandrik requested a review from Copilot May 20, 2025 16:58
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 fixes the issue where paginated tables in groups were not scrolled to the top on refresh by refactoring scrolling logic and updating component props.

  • Replaces the old "parentRef" prop with the new "scrollContainerRef" across multiple components.
  • Updates table layout and scroll behavior with the new useTableScroll hook and revised CSS variables.
  • Introduces wrapper components (e.g., StorageNodesControlsWithTableState, StorageGroupGroup) and switches to PaginatedTableWithLayout for improved state management and scrolling.

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/containers/Storage/TableGroup/TableGroup.tsx Refactored TableGroup to an arrow function and set displayName.
src/containers/Storage/StorageNodes/PaginatedStorageNodesTable.tsx Replaced parentRef with scrollContainerRef and removed renderControls.
src/containers/Storage/StorageGroups/PaginatedStorageGroupsTable.tsx Consistently updated prop names and types; similar changes as StorageNodes table.
src/containers/Storage/PaginatedStorageNodes.tsx Updated scroll container handling and introduced new wrapper components.
src/containers/Storage/PaginatedStorageGroups.tsx Similar scroll refactoring and integration with PaginatedTableWithLayout.
Various files in Nodes, PDiskPage, Cluster, and Table component directories Replaced parentRef with scrollContainerRef and updated scrolling behavior accordingly.
src/components/TableWithControlsLayout Introduced useTableScroll hook and updated layout styles.
src/components/PaginatedTable/* Updated types, context, and scroll handling logic to align with new naming and scrolling mechanisms.
Comments suppressed due to low confidence (1)

src/components/PaginatedTable/types.ts:68

  • Verify that the change to the RenderControls type signature (removing parameters) does not break any existing implementations that might rely on receiving control state parameters.
export type RenderControls = () => React.ReactNode;

@astandrik
Copy link
Collaborator Author

splitted PaginatedStorageNodes and PaginatedStorageGroups to directories as they are totally uncomprehensible as single large files

@astandrik astandrik requested a review from Copilot May 20, 2025 18:02
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 refactors table scrolling logic to support a unified scrollContainerRef, replaces legacy parentRef props, and integrates useTableScroll for automatic scroll adjustments.

  • Swapped parentRef for scrollContainerRef across storage, nodes, cluster, and paginated table components
  • Introduced useTableScroll in TableWithControlsLayout.Table and propagated scrollDependencies for automatic repositioning
  • Updated SCSS variables for sticky header offsets and added full-height support

Reviewed Changes

Copilot reviewed 67 out of 67 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/components/TableWithControlsLayout/TableWithControlsLayout.tsx Added scrollContainerRef and useTableScroll integration
src/components/TableWithControlsLayout/useTableScroll.ts New hook to align tables within scroll containers
src/components/PaginatedTable/PaginatedTable.tsx Removed parentRef, adopted context state, reset logic updated
src/components/PaginatedTable/useScrollBasedChunks.ts Renamed parentRefscrollContainerRef
src/components/PaginatedTable/PaginatedTableWithLayout.tsx New wrapper using PaginatedTableProvider and full-height support
src/containers/Storage/... Replaced parentRef with scrollContainerRef in all storage-related paginated components
src/containers/Nodes/... Updated to use scrollContainerRef in Nodes and NodesTable
src/containers/Cluster/Cluster.tsx Propagated scrollContainerRef to TabletsTable, Tenants, Nodes, and PaginatedStorage
src/containers/PDiskPage/PDiskPage.tsx Swapped parentRef for scrollContainerRef in <PaginatedStorage> invocation
src/containers/Storage/PaginatedStorage.tsx Renamed prop parentRefscrollContainerRef
src/containers/Storage/PaginatedStorageGroups/... Updated all related components to use scrollContainerRef
Comments suppressed due to low confidence (3)

src/components/PaginatedTable/PaginatedTable.tsx:128

  • The manual scroll-to-top on filter or data refresh was removed; without calling scrollContainerRef.current.scrollTo(0, 0), users may remain mid-scroll after updates. Consider adding scrollContainerRef?.current?.scrollTo(0, 0); inside this effect to reset the viewport.
React.useLayoutEffect(() => {

src/containers/Storage/PaginatedStorageGroups/PaginatedStorageGroups.tsx:21

  • [nitpick] There is a typo in the variable name storageGroupsHandlerHasGroupping (double 'p'). Please rename to storageGroupsHandlerHasGrouping for consistency and clarity.
const storageGroupsHandlerHasGroupping = useStorageGroupsHandlerHasGrouping();

src/components/TableWithControlsLayout/useTableScroll.ts:102

  • The new scroll adjustment logic in useTableScroll lacks dedicated unit or integration tests. Consider adding tests that simulate container scroll and dependency changes to verify correct offset calculations and behavior.
React.useLayoutEffect(() => {

@Raubzeug
Copy link
Contributor

Screen.Recording.2025-05-21.at.09.36.19.mov

@astandrik
Copy link
Collaborator Author

@Raubzeug as for now all known issues should be fixed (your screencast too)

Stand redeployed

@astandrik
Copy link
Collaborator Author

@Raubzeug conflicts resolved

stand redeployed

const {sortParams, foundEntities} = tableState;

// Initialize state with props if available
React.useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not pass initialSortParams and initialEntitiesCount as part of initial state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


display: inline-block;

box-sizing: border-box;
min-width: 100%;

&_fullHeight {
Copy link
Contributor

Choose a reason for hiding this comment

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

lets not use camel case in css

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 added this pull request to the merge queue May 22, 2025
Merged via the queue into main with commit f4971ee May 22, 2025
8 checks passed
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: paginated table in groups scrolled to top on refresh
2 participants