## Infinite Scroll Improvements for TableWidgetV2
This PR enhances the infinite scroll functionality in `TableWidgetV2`
with several key improvements:
---
### 🚀 Major Changes
#### 1️⃣ Improved Loading State Management
- Added a `shouldShowSkeleton()` function to determine when to display
loading skeletons.
- Loading skeletons now only show when:
- Loading without infinite scroll enabled.
- Loading with infinite scroll but no data loaded yet.
- Added a dedicated loading indicator for infinite scroll that appears
at the bottom while fetching more data.
#### 2️⃣ Enhanced Infinite Scroll Implementation
- Completely refactored `useInfiniteVirtualization` hook to properly
cache and manage loaded rows.
- Added row caching to maintain previously loaded pages when new data
arrives.
- Improved detection of end-of-data conditions to prevent unnecessary
load attempts.
- Fixed issues with item count calculations and loading state
management.
#### 3️⃣ Better Virtualization Support
- Fixed issues with virtual list rendering by properly passing
`itemCount`.
- Added support for `totalRecordsCount` to optimize infinite scroll
behavior.
- Improved table wrapper class name management with a dedicated
function.
---
### 🧪 Testing
This PR includes **comprehensive test coverage** for the infinite scroll
functionality, with **12 detailed test cases** covering:
- ✅ Page loading and caching behavior.
- ✅ End-of-data detection.
- ✅ Partial page handling.
- ✅ Loading state management.
Fixes#39083
## Automation
/ok-to-test tags="@tag.Binding, @tag.Sanity, @tag.Table, @tag.Widget"
### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results -->
> [!TIP]
> 🟢🟢🟢 All cypress tests have passed! 🎉🎉🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13651510022>
> Commit: 3bbfda7143ee29eff70e59d234d6e89c74d8bb88
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13651510022&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Binding, @tag.Sanity, @tag.Table, @tag.Widget`
> Spec:
> <hr>Tue, 04 Mar 2025 11:47:11 UTC
<!-- end of auto-generated comment: Cypress test results -->
## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
## Summary by CodeRabbit
- **New Features**
- Introduced support for displaying the total number of records,
improving context for pagination and data navigation.
- Added a loading indicator that displays conditionally based on the
loading state.
- **Refactor**
- Refined loading state visuals so that the skeleton indicator appears
only when appropriate.
- Enhanced infinite scrolling and virtualization behavior for smoother
and more reliable data rendering.
- Strengthened row indexing to improve overall robustness.
- Improved the structure and readability of the `Table` component's
rendering logic.
- Updated test suite for dynamic row generation and various loading
scenarios, enhancing flexibility and comprehensiveness.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->