Skip to content

fix: Enhanced offline data handling capabilities for the data table when infinite scroll is enabled.#40632

Merged
rahulbarwal merged 4 commits intoreleasefrom
rahulbarwal/issue40579/Bug-Infinte-scroll-After-Network-Failure-an-error-message-is-displayed-later-the-the-user-is-not-able-to-retry-loading-data
May 14, 2025
Merged

fix: Enhanced offline data handling capabilities for the data table when infinite scroll is enabled.#40632
rahulbarwal merged 4 commits intoreleasefrom
rahulbarwal/issue40579/Bug-Infinte-scroll-After-Network-Failure-an-error-message-is-displayed-later-the-the-user-is-not-able-to-retry-loading-data

Conversation

@rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented May 12, 2025

Description

Problem
Table failed to load data for a page when network or query failures occurred with infinite scroll enabled.

Root cause
There was no fallback or handling mechanism for offline scenarios or query failures, causing the table to enter an unusable state.

Solution
This PR handles enhancing offline data handling for the table when infinite scroll is enabled.
We ensure that a data fetch request for the next page is triggered regardless of the scenario.

  • For example, if we are on page 2 and attempt to navigate to page 3, but the network request fails due to being offline or a timeout, we recognize that we lack data for page 3. If the user reverse scrolls and then resumes scrolling toward page 3, we will issue a new request.
  • This process relies on accurately tracking the current page and the user's scrolling intent, while also checking the data we have already received.

Fixes #40579
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="@tag.Table"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/15011754024
Commit: 9c48e7c
Cypress dashboard.
Tags: @tag.Table
Spec:


Wed, 14 May 2025 04:22:05 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Improved infinite scroll in tables with enhanced data caching, reducing redundant data requests and improving performance during pagination.
    • Table components now leverage cached data for smoother scrolling and more efficient page loading.
  • Performance
    • Optimized table rendering to prevent unnecessary re-renders when cached data remains unchanged.
  • Bug Fixes
    • Prevented updates to end-of-data status when offline, avoiding incorrect data state during connectivity issues.

…nfinite scroll is enabled.

Neither network failures nor query failures should lead the table into a state where it is unable to load the data for that page.
@rahulbarwal rahulbarwal requested a review from a team as a code owner May 12, 2025 06:17
@rahulbarwal rahulbarwal requested review from jacquesikot and removed request for a team May 12, 2025 06:17
@rahulbarwal rahulbarwal self-assigned this May 12, 2025
@rahulbarwal rahulbarwal requested review from AmanAgarwal041 and removed request for jacquesikot May 12, 2025 06:17
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 12, 2025

Walkthrough

The changes enhance the infinite scroll mechanism in the TableWidgetV2 by introducing page-aware loading, explicit data caching, and event-based page updates. New props for cached data and page update functions are added and propagated through the component hierarchy, and memoization is updated to account for cached data changes.

Changes

Files Change Summary
.../TableWidgetV2/component/VirtualTable/InifiniteScrollBody/index.tsx Added cachedTableData and updatePageNo from useAppsmithTable() and passed them to useInfiniteScroll.
.../TableWidgetV2/component/VirtualTable/InifiniteScrollBody/useInfiniteScroll.tsx Enhanced infinite scroll logic: replaced loadMore with updatePageNo, added cachedTableData, refined scroll/load triggers, and improved page-based loading and caching.
.../TableWidgetV2/component/index.tsx Extended ReactTableComponentProps with cachedTableData, passed it to Table, and updated memoization to include deep equality on cachedTableData.
.../TableWidgetV2/component/types.ts Added cachedTableData property to TableProps interface.
.../TableWidgetV2/widget/index.tsx Passed cachedTableData prop from widget props to ReactTableComponent and updated endOfData logic to consider online status.
.../TableWidgetV2/component/TableContext.test.tsx Added cachedTableData as an empty array to mock context props in tests.
.../TableWidgetV2/component/header/actions/Actions.test.tsx Added cachedTableData as an empty array to default props in test setup.

Sequence Diagram(s)

sequenceDiagram
  participant Widget
  participant ReactTableComponent
  participant Table
  participant InfiniteScrollBody
  participant useInfiniteScroll

  Widget->>ReactTableComponent: Pass cachedTableData
  ReactTableComponent->>Table: Pass cachedTableData
  Table->>InfiniteScrollBody: Pass cachedTableData, updatePageNo
  InfiniteScrollBody->>useInfiniteScroll: Use cachedTableData, updatePageNo

  useInfiniteScroll->>useInfiniteScroll: On scroll event, check cachedTableData
  alt Data not cached
    useInfiniteScroll->>updatePageNo: Trigger load for next page (ON_NEXT_PAGE)
  end
Loading

Assessment against linked issues

Objective Addressed Explanation
Allow retrying data load after network failure in infinite scroll table (Issue #40579)

Possibly related PRs

Suggested labels

Enhancement, Production

Suggested reviewers

  • AmanAgarwal041
  • jacquesikot

Poem

Scroll on, scroll on, through data's endless stream,
With caches now in tow, and retries in the scheme.
No more stuck at "loading,"
When networks misbehave—
The Table marches forward,
For infinite scroll, we crave!
🚀🗃️

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 831e83b and 9c48e7c.

📒 Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/component/TableContext.test.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/widgets/TableWidgetV2/component/TableContext.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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 Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Query Widgets & IDE Pod All issues related to Query, JS, Eval, Widgets & IDE Release Table Widget V2 Issues related to Table Widget V2 Widgets Product This label groups issues related to widgets labels May 12, 2025
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: 2

🔭 Outside diff range comments (1)
app/client/src/widgets/TableWidgetV2/component/VirtualTable/InifiniteScrollBody/useInfiniteScroll.tsx (1)

63-65: ⚠️ Potential issue

Missing deps will cause stale closures

debouncedLoadMore uses updatePageNo and cachedTableData, but they are not listed in the dependency array.
If either changes (e.g. widget re-initialises, new cache object), the callback will still reference the old values, leading to pages never loading or loading twice.

-    [isLoading, endOfData, loadMore],
+    [isLoading, endOfData, loadMore, updatePageNo, cachedTableData],
🧹 Nitpick comments (2)
app/client/src/widgets/TableWidgetV2/component/VirtualTable/InifiniteScrollBody/useInfiniteScroll.tsx (2)

40-57: loadMore param is now redundant

Inside the debounced callback you no longer call loadMore; the new flow relies on updatePageNo.
Consider dropping loadMore from UseInfiniteScrollProps to avoid confusion and dead code paths.


34-35: lastPageInTableDataset recalculated every render

Since it derives directly from rows.length and pageSize, memoising it with useMemo would avoid recomputation and make the dependency list explicit. Not critical, but keeps renders lean.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7322d72 and 7b1b3af.

📒 Files selected for processing (5)
  • app/client/src/widgets/TableWidgetV2/component/VirtualTable/InifiniteScrollBody/index.tsx (2 hunks)
  • app/client/src/widgets/TableWidgetV2/component/VirtualTable/InifiniteScrollBody/useInfiniteScroll.tsx (2 hunks)
  • app/client/src/widgets/TableWidgetV2/component/index.tsx (3 hunks)
  • app/client/src/widgets/TableWidgetV2/component/types.ts (1 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/index.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (7)
app/client/src/widgets/TableWidgetV2/widget/index.tsx (1)

1305-1305: Appropriate prop forwarding for cached table data.

The new cachedTableData prop is correctly passed from the widget to the ReactTableComponent, enabling offline data handling for the infinite scroll table.

app/client/src/widgets/TableWidgetV2/component/VirtualTable/InifiniteScrollBody/index.tsx (2)

16-17: Properly destructure required props from context.

The component now correctly retrieves cachedTableData and updatePageNo from the table context.

Also applies to: 24-24


33-34: Enhanced infinite scroll with cached data support.

The useInfiniteScroll hook now receives updatePageNo and cachedTableData parameters, enabling page-aware loading and preventing redundant data fetches during network failures.

app/client/src/widgets/TableWidgetV2/component/types.ts (1)

84-84: Proper type definition for cached data.

The TableProps interface has been correctly extended with a cachedTableData property of type Array<Record<string, unknown>>, maintaining type consistency with the table data structure.

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

112-112: Well-defined prop interface for cached data.

The ReactTableComponentProps interface has been properly extended with the cachedTableData property, ensuring type safety throughout the component.


247-247: Appropriate prop passing to child component.

The cachedTableData prop is correctly forwarded to the Table component, maintaining consistent data flow through the component hierarchy.


361-362: Updated memoization with proper equality check.

The memoization comparison now includes a deep equality check for cachedTableData using the equal function, preventing unnecessary re-renders when the cached data references change but the content remains the same.

@rahulbarwal rahulbarwal added the ok-to-test Required label for CI label May 12, 2025
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/14969000435.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 40632.
recreate: .

@github-actions
Copy link

Deploy-Preview-URL: https://ce-40632.dp.appsmith.com

…g conditions and add debug logging.

- Added a check to ensure that `cachedTableData[pageToLoad]` has data before attempting to load more.
- Updated the end-of-data condition to consider the online status of the user, ensuring more reliable data handling during network fluctuations.
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/14990261999.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 40632.
recreate: .

@github-actions
Copy link

Deploy-Preview-URL: https://ce-40632.dp.appsmith.com

AmanAgarwal041
AmanAgarwal041 previously approved these changes May 13, 2025
Copy link
Contributor

@AmanAgarwal041 AmanAgarwal041 left a comment

Choose a reason for hiding this comment

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

Working fine.

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels May 14, 2025
@rahulbarwal rahulbarwal merged commit 6c8b040 into release May 14, 2025
43 checks passed
@rahulbarwal rahulbarwal deleted the rahulbarwal/issue40579/Bug-Infinte-scroll-After-Network-Failure-an-error-message-is-displayed-later-the-the-user-is-not-able-to-retry-loading-data branch May 14, 2025 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Query Widgets & IDE Pod All issues related to Query, JS, Eval, Widgets & IDE Release Table Widget V2 Issues related to Table Widget V2 Widgets Product This label groups issues related to widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [Infinte scroll] After Network Failure an error message is displayed, later the the user is not able to retry loading data.

2 participants