Skip to content
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

feat: implement infinite scroll with dynamic height #39646

Draft
wants to merge 3 commits into
base: release
Choose a base branch
from

Conversation

jacquesikot
Copy link
Contributor

@jacquesikot jacquesikot commented Mar 10, 2025

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags=""

🔍 Cypress test results

Warning

Tests have not run on the HEAD d645c32 yet


Wed, 12 Mar 2025 08:15:58 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Tables now dynamically adjust row heights based on cell content, including support for text wrapping.
    • List rendering has been enhanced to support variable row sizes, ensuring a smoother and more responsive display.
    • Automatic row measurement updates provide consistent layouts as content changes.

@jacquesikot jacquesikot requested a review from a team as a code owner March 10, 2025 08:00
@jacquesikot jacquesikot requested review from rahulbarwal and removed request for a team March 10, 2025 08:00
Copy link
Contributor

coderabbitai bot commented Mar 10, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This change set enhances the TableWidgetV2 by introducing dynamic row measurement and variable row sizing. The modifications update the Row component to use a new interface and measurement logic via hooks, adjust the VirtualList component to compute row sizes dynamically, and expand the TableBody context to manage measurement state with additional refs.

Changes

File(s) Change Summary
app/client/.../Row.tsx Added CellWithColumnProps interface, integrated useRef and useEffect to measure cell heights, and updated rowProps with row DOM references.
app/client/.../VirtualList.tsx Replaced FixedSizeList with VariableSizeList, updated infiniteLoaderListRef type, introduced BodyContext with listRef and rowHeights, added combinedRef and getItemSize for dynamic sizing.
app/client/.../index.tsx Introduced new refs (listRef, rowHeights, rowNeedsMeasurement) and a useEffect to reset measurement flags; updated BodyContextType and provider with these refs.

Sequence Diagram(s)

sequenceDiagram
    participant Row as Row Component
    participant Ref as useRef Hook
    participant Effect as useEffect Hook
    participant Context as BodyContext
    participant VList as VirtualList Component

    Row->>Ref: Create row DOM reference
    Row->>Effect: Trigger measurement on mount/update
    Effect->>Row: Calculate cell heights based on content and allowCellWrapping
    Row->>Context: Update rowHeights and measurement flag
    VList->>Context: Retrieve current rowHeights
    VList->>VList: Compute item size via getItemSize
Loading

Possibly related PRs

Suggested labels

Enhancement, Widgets Product, Task, Table Widget V2, ok-to-test, Widgets & Accelerators Pod, Query & Widgets Pod

Suggested reviewers

  • AmanAgarwal041
  • rahulbarwal
  • vivek-appsmith

Poem

Rows that grow and lists that flex,
A measured dance in code's complex.
Hooks align with purpose true,
Dynamic heights now shine through ✨.
Cheers to changes fresh anew!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Enhancement New feature or request label Mar 10, 2025
@jacquesikot jacquesikot marked this pull request as draft March 10, 2025 08:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/client/src/widgets/TableWidgetV2/component/TableBody/Row.tsx (1)

48-125: Refinement on error handling & optional chaining
The measuring logic is well-structured but silently catches all errors, which can obscure unexpected issues. Consider logging or handling them more specifically.
Meanwhile, applying an optional chain at line 124 aligns with safer property access:

- rowNeedsMeasurement.current && (rowNeedsMeasurement.current[index] = false);
+ rowNeedsMeasurement.current?.[index] = false;
🧰 Tools
🪛 Biome (1.9.4)

[error] 124-124: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a206933 and 034bba2.

📒 Files selected for processing (3)
  • app/client/src/widgets/TableWidgetV2/component/TableBody/Row.tsx (3 hunks)
  • app/client/src/widgets/TableWidgetV2/component/TableBody/VirtualList.tsx (4 hunks)
  • app/client/src/widgets/TableWidgetV2/component/TableBody/index.tsx (5 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/widgets/TableWidgetV2/component/TableBody/Row.tsx

[error] 124-124: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (20)
app/client/src/widgets/TableWidgetV2/component/TableBody/Row.tsx (7)

2-2: Looks good.
This import is appropriate for the new hooks usage and poses no issues.


8-12: Constants import
Neat import of constants for table sizing and styling.


21-27: Clear interface definition
This interface addition keeps the cell props explicit, aiding readability.


31-31: Prop destructuring
Extracting props here promotes clarity.


37-37: Retrieving listRef
Grabbing the list reference from context is a clean approach for virtualization.


41-42: Context-based row measurements
Acquiring rowHeights and rowNeedsMeasurement from context effectively enables dynamic row resizing.


160-160: Ref assignment
Binding rowRef to the row DOM element is crucial for accurate height measurement.

app/client/src/widgets/TableWidgetV2/component/TableBody/VirtualList.tsx (6)

2-9: Necessary imports
Bringing in the relevant types and hooks for variable-size virtualization.


11-13: BodyContext usage
Importing BodyContext aligns the virtual list with the dynamic row measurement paradigm.


42-42: Ref type update
Switching to React.Ref is consistent with the variable sizing approach.


57-57: Destructuring from context
Extracting listRef and rowHeights sets up the foundation for dynamic sizing logic.


59-89: Combining refs & computing item size
Merging the infiniteLoaderListRef and listRef is convenient, and the getItemSize callback nicely accommodates variable row heights.


92-110: VariableSizeList integration
Leveraging dynamic row sizing with an estimated item size is a solid choice for better rendering performance.

app/client/src/widgets/TableWidgetV2/component/TableBody/index.tsx (7)

1-1: Imports
No issues; this suits the new hooks and effect usage.


7-7: Importing VariableSizeList
Needed to enable variable row height logic.


36-38: Enhancement to BodyContextType
Adding rowHeights, rowNeedsMeasurement, and listRef defines the backbone for measuring rows.


53-55: Default context initialization
Providing default ref objects ensures consistent behavior throughout.


142-145: Creating ref state
The useRef hooks for listRef, rowHeights, and rowNeedsMeasurement help centralize row dimension tracking.


147-149: Row measurement reset
Reinitializing rowNeedsMeasurement on row changes is a clean way to handle newly rendered rows.


182-185: Context provider additions
Populating rowHeights, rowNeedsMeasurement, and listRef in BodyContext completes the dynamic resizing infrastructure.

Copy link

🔴🔴🔴 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

You can view the dependency diff in the run log. Look for the check-cyclic-dependencies job in the run.

…asurement

- Added a new hook `useColumnVariableHeight` to manage dynamic row heights
- Introduced a force update mechanism to trigger row height recalculation
- Renamed `FixedInfiniteVirtualList` to `VariableHeightInfiniteVirtualList` for clarity
- Improved error handling and type safety in row height measurement
- Simplified cell wrapping detection logic
Copy link

🔴🔴🔴 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

You can view the dependency diff in the run log. Look for the check-cyclic-dependencies job in the run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant