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: Introduce infinite scroll feature behind feature flag. #39207

Conversation

rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Feb 12, 2025

Description

  • Adding infiniteScrollEnabled prop to TableWidgetProps
  • Added feature flag: release_tablev2_infinitescroll_enabled to control this.

Fixes #39079
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, @tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13305863325
Commit: 182c03d
Cypress dashboard.
Tags: @tag.Table, @tag.Sanity
Spec:


Thu, 13 Feb 2025 11:35:05 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Introduced an option to enable infinite scrolling in table views. When activated, tables automatically adjust scrolling behavior and pagination controls, enhancing data browsing.
  • Tests
    • Updated test cases to verify the new infinite scrolling functionality, ensuring it is disabled by default.

Copy link
Contributor

coderabbitai bot commented Feb 12, 2025

Walkthrough

This pull request introduces a new feature flag (release_tablev2_infinitescroll_enabled) to enable infinite scrolling in the table widget. It adds boolean properties (isInfiniteScrollEnabled and infiniteScrollEnabled) to several component interfaces and types. The rendering logic is updated so that the table components choose between virtual rendering and infinite scrolling based on these properties. Configuration files and tests are also modified to support the new infinite scroll behavior.

Changes

Files Change Summary
app/client/src/ce/entities/FeatureFlag.ts Added new feature flag release_tablev2_infinitescroll_enabled and its default value false to the FEATURE_FLAG and DEFAULT_FEATURE_FLAG_VALUE objects.
app/client/src/widgets/TableWidgetV2/component/(Table.tsx, TableBody/index.tsx, VirtualTable.tsx, index.tsx) Introduced the isInfiniteScrollEnabled property in component interfaces (TableProps, BodyPropsType, VirtualTableProps, ReactTableComponentProps) and updated render logic to support infinite scrolling.
app/client/src/widgets/TableWidgetV2/constants.ts Added infiniteScrollEnabled property to TableWidgetProps and created constant INFINITE_SCROLL_ENABLED referencing the new feature flag.
app/client/src/widgets/TableWidgetV2/widget/index.tsx Passed the isInfiniteScrollEnabled property to the ReactTableComponent in the getWidgetView method.
app/client/src/widgets/TableWidgetV2/widget/propertyConfig/contentConfig.ts Updated the pagination configuration to include an infiniteScrollEnabled switch and adjusted pagination visibility based on this property.
app/client/src/widgets/TableWidgetV2/widget/__tests__/TableRendered.test.ts Updated test cases by adding infiniteScrollEnabled: false to the tableWidgetProps object.

Sequence Diagram(s)

sequenceDiagram
    participant Widget as TableWidgetV2
    participant Table as Table Component
    participant VT as VirtualTable
    participant TB as TableBody

    Widget->>Table: Pass isInfiniteScrollEnabled flag
    alt Infinite Scroll Enabled
        Table->>VT: Render VirtualTable with isInfiniteScrollEnabled=true
        VT->>TB: Forward isInfiniteScrollEnabled prop
        TB->>Widget: Render infinite scroll UI
    else
        Table->>Widget: Render static table view
    end
Loading

Possibly related PRs

Suggested labels

High

Suggested reviewers

  • AmanAgarwal041
  • jacquesikot

Poem

In the code's realm, a flag now gleams,
Infinite scroll dreams wander in streams.
Components align with a new design,
Prop by prop, everything falls in line.
A scroll of magic in our digital art,
Cheers to progress—each pull plays its part!
🚀 Happy coding!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

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 (2)
app/client/src/widgets/TableWidgetV2/widget/index.tsx (1)

190-235: 🛠️ Refactor suggestion

Add default value for infiniteScrollEnabled property.

The infiniteScrollEnabled property should be initialized in the getDefaults() method to ensure consistent behavior.

Apply this diff to add the default value:

  static getDefaults() {
    return {
      flexVerticalAlignment: FlexVerticalAlignment.Top,
      responsiveBehavior: ResponsiveBehavior.Fill,
      minWidth: FILL_WIDGET_MIN_WIDTH,
      rows: 28,
      canFreezeColumn: true,
      columnUpdatedAt: Date.now(),
      columns: 34,
      animateLoading: true,
      defaultSelectedRowIndex: 0,
      defaultSelectedRowIndices: [0],
      label: "Data",
      widgetName: "Table",
      searchKey: "",
      textSize: "0.875rem",
      horizontalAlignment: "LEFT",
      verticalAlignment: "CENTER",
      totalRecordsCount: 0,
      defaultPageSize: 0,
      dynamicPropertyPathList: [],
      borderColor: Colors.GREY_5,
      borderWidth: "1",
      dynamicBindingPathList: [],
      primaryColumns: {},
      tableData: "",
      columnWidthMap: {},
      columnOrder: [],
      enableClientSideSearch: true,
      isVisibleSearch: true,
      isVisibleFilters: false,
      isVisibleDownload: true,
      isVisiblePagination: true,
      isSortable: true,
      delimiter: ",",
      version: 2,
      inlineEditingSaveOption: InlineEditingSaveOptions.ROW_LEVEL,
+     infiniteScrollEnabled: false,
      enableServerSideFiltering: TableWidgetV2.getFeatureFlag(
        ALLOW_TABLE_WIDGET_SERVER_SIDE_FILTERING,
      )
        ? false
        : undefined,
      customIsLoading: false,
      customIsLoadingValue: "",
    };
  }
app/client/src/widgets/TableWidgetV2/component/index.tsx (1)

289-346: ⚠️ Potential issue

Add memo comparison for the new infinite scroll prop.

The React.memo comparison function should include the new isInfiniteScrollEnabled prop to prevent unnecessary re-renders.

 export default React.memo(ReactTableComponent, (prev, next) => {
   return (
     prev.applyFilter === next.applyFilter &&
     prev.compactMode === next.compactMode &&
     prev.delimiter === next.delimiter &&
+    prev.isInfiniteScrollEnabled === next.isInfiniteScrollEnabled &&
     // ... rest of the comparisons
     prev.showConnectDataOverlay === next.showConnectDataOverlay
   );
 });
🧹 Nitpick comments (2)
app/client/src/widgets/TableWidgetV2/widget/propertyConfig/contentConfig.ts (1)

177-185: Improve the help text for infinite scroll property.

The current help text appears to be copied from the pagination property. Consider updating it to better describe the infinite scroll behavior and its implications.

-        helpText:
-          "Bind the Table.pageNo property in your API and call it onPageChange",
+        helpText:
+          "Enable infinite scrolling to automatically load more data as the user scrolls to the bottom of the table",
app/client/src/widgets/TableWidgetV2/constants.ts (1)

251-252: Consider adding JSDoc comment for the feature flag constant.

While the constant follows the established pattern, adding documentation would help other developers understand its purpose and impact.

+/** Feature flag to enable infinite scrolling functionality in TableWidgetV2 */
 export const INFINITE_SCROLL_ENABLED =
   FEATURE_FLAG["release_tablev2_infinitescroll_enabled"];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9aa065b and 6a15d81.

📒 Files selected for processing (9)
  • app/client/src/ce/entities/FeatureFlag.ts (2 hunks)
  • app/client/src/widgets/TableWidgetV2/component/StaticTable.tsx (1 hunks)
  • app/client/src/widgets/TableWidgetV2/component/Table.tsx (4 hunks)
  • app/client/src/widgets/TableWidgetV2/component/TableBody/index.tsx (3 hunks)
  • app/client/src/widgets/TableWidgetV2/component/VirtualTable.tsx (2 hunks)
  • app/client/src/widgets/TableWidgetV2/component/index.tsx (3 hunks)
  • app/client/src/widgets/TableWidgetV2/constants.ts (2 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/index.tsx (1 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/propertyConfig/contentConfig.ts (3 hunks)
🔇 Additional comments (9)
app/client/src/widgets/TableWidgetV2/component/VirtualTable.tsx (1)

40-40: LGTM! Clean prop addition and passing.

The implementation correctly adds and propagates the infinite scroll property.

Also applies to: 63-63

app/client/src/widgets/TableWidgetV2/component/StaticTable.tsx (1)

84-84: LGTM! Appropriate hardcoding for static table.

Correctly disables infinite scroll for static table implementation.

app/client/src/ce/entities/FeatureFlag.ts (1)

57-58: LGTM! Feature flag follows conventions.

The feature flag is correctly defined and initialized with a safe default value of false.

Also applies to: 104-104

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

82-82: LGTM! Clean prop type addition.

The property is correctly typed in the BodyPropsType interface.


197-197: Verify prop passing in child components.

The isInfiniteScrollEnabled prop is being passed as false to both TableVirtualBodyComponent and TableBodyComponent, but these components don't declare this prop in their interfaces.

Also applies to: 205-206

❌ Incorrect review comment

🏁 Script executed:

#!/bin/bash
# Check if these components declare the prop in their interfaces
ast-grep --pattern 'interface $_ {
  $$$
  isInfiniteScrollEnabled: boolean;
  $$$
}'

Length of output: 14506


Prop Declaration Confirmed in Component Interfaces

  • In app/client/src/widgets/TableWidgetV2/component/TableBody/index.tsx, the BodyPropsType interface declares isInfiniteScrollEnabled: boolean; (line 82).
  • In app/client/src/widgets/TableWidgetV2/component/Table.tsx, the interface TableProps declares isInfiniteScrollEnabled: boolean; (line 137).

Based on the grep results, both child components correctly declare the property, so no further changes are needed.

Likely an incorrect or invalid review comment.

app/client/src/widgets/TableWidgetV2/component/Table.tsx (1)

338-345: LGTM!

The virtual scrolling logic is correctly implemented with the new infinite scroll feature. The props are properly passed to the appropriate components, and the conditions for enabling virtual scrolling are well-defined.

Also applies to: 492-492, 514-514

app/client/src/widgets/TableWidgetV2/constants.ts (1)

114-114: LGTM: Property addition follows TypeScript conventions.

The infiniteScrollEnabled boolean property is correctly added to the TableWidgetProps interface.

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

109-109: LGTM: Property addition follows React prop typing conventions.

The isInfiniteScrollEnabled boolean property is correctly added to the ReactTableComponentProps interface.


135-135: LGTM: Proper prop destructuring and passing.

The infinite scroll property is correctly destructured from props and passed down to the Table component.

Also applies to: 251-251

Comment on lines +193 to +195
{isInfiniteScrollEnabled ? (
<div>Infinite Scroll</div>
) : useVirtual ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Placeholder needs implementation.

The current implementation only shows a placeholder div. This needs to be replaced with actual infinite scroll functionality.

Would you like me to help create a proper infinite scroll implementation using react-window's FixedSizeList with onScroll handling?

@@ -1310,6 +1310,7 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
height={componentHeight}
isAddRowInProgress={this.props.isAddRowInProgress}
isEditableCellsValid={this.props.isEditableCellsValid}
isInfiniteScrollEnabled={this.props.infiniteScrollEnabled}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify interaction with pagination controls.

The infinite scroll feature might affect the visibility and behavior of pagination controls. Ensure that pagination controls are hidden when infinite scroll is enabled.


🏁 Script executed:

#!/bin/bash
# Description: Check if pagination controls are properly handled with infinite scroll.

# Search for pagination visibility logic
rg -A 5 "isVisiblePagination" 

Length of output: 105089


Action Required: Hide Pagination Controls When Infinite Scroll Is Enabled

The DSL fixtures show that the pagination flag ("isVisiblePagination") is always set to true. There is no apparent logic in the widget that conditionally hides pagination when the infinite scroll feature (mapped via the prop "infiniteScrollEnabled") is enabled. You should ensure that the widget's runtime behavior overrides the DSL setting (or updates it accordingly) so that pagination controls are hidden when infinite scroll is active.

  • Check and update the conditional rendering logic in the widget (e.g., in TableWidgetV2) to disable pagination when infiniteScrollEnabled is true.
  • Update or transform the DSL configuration at runtime to reflect that pagination should be hidden if infinite scrolling is enabled.

@rahulbarwal rahulbarwal changed the title Rahulbarwal/issue39079/Feature-flag-to-control-visibility-of-this-feature feat: Introduce infinite scroll feature behind feature flag. Feb 12, 2025
…o rahulbarwal/issue39079/Feature-flag-to-control-visibility-of-this-feature
@github-actions github-actions bot added Query & Widgets Pod All issues related to Query, JS, Eval, and Widgets Table Widget V2 Issues related to Table Widget V2 Task A simple Todo Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets labels Feb 12, 2025
@rahulbarwal rahulbarwal added the ok-to-test Required label for CI label Feb 12, 2025
@github-actions github-actions bot added the Enhancement New feature or request label Feb 12, 2025
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

@@ -81,6 +81,7 @@ const StaticTable = (props: StaticTableProps, ref: React.Ref<SimpleBar>) => {
getTableBodyProps={props.getTableBodyProps}
height={props.height}
isAddRowInProgress={props.isAddRowInProgress}
isInfiniteScrollEnabled={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

As we have added the feature flag, shouldn't we make use of that here instead of making it false always ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Static table is never going to use infinite scroll. So basically the idea behind infinite scroll is that it will always use virtual table.

Why do we have to pass this when static table is not using this variable? So this is just baggage that we have from earlier structuring of code. I am planning to handle this in my next PR where I will try to do a refactor if possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this prop is a new prop then we can mark this as the optional prop which would be undefined by default which will solve the purpose instead of passing false to this prop explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what I am forced to do right now but I don't like it to be honest. Ideally I should not have to write any piece of code that I don't need.
If instead of hard coding it to false, if I give it a variable that means that the JS compiler has to evaluate that value before passing it down here. Which in this case might be a moot point but still in principle I should not have to write what I don't need.

What I am proposing is eliminating this unnecessary code in a refactor PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We met over a call and agreed to make this an optional argument and deal with this whole component structure in a separate PR.

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

♻️ Duplicate comments (1)
app/client/src/widgets/TableWidgetV2/component/TableBody/index.tsx (1)

193-195: ⚠️ Potential issue

Placeholder needs implementation.

The current implementation only shows a placeholder div. This needs to be replaced with actual infinite scroll functionality.

Would you like me to help create a proper infinite scroll implementation using react-window's FixedSizeList with onScroll handling?

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

196-202: Consider removing redundant prop passing.

The isInfiniteScrollEnabled={false} prop is being explicitly passed to child components that don't use it. This creates unnecessary prop drilling.

 <TableVirtualBodyComponent
-  isInfiniteScrollEnabled={false}
   ref={ref}
   rows={rows}
   width={width}
   {...restOfProps}
 />

 <TableBodyComponent
-  isInfiniteScrollEnabled={false}
   rows={rows}
   {...restOfProps}
 />

Also applies to: 204-208

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 037e613 and 182c03d.

📒 Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/component/TableBody/index.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • 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 (1)
app/client/src/widgets/TableWidgetV2/component/TableBody/index.tsx (1)

82-82: LGTM!

Clean addition of the optional boolean prop to the interface.

@rahulbarwal rahulbarwal merged commit 2607655 into release Feb 14, 2025
45 checks passed
@rahulbarwal rahulbarwal deleted the rahulbarwal/issue39079/Feature-flag-to-control-visibility-of-this-feature branch February 14, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request ok-to-test Required label for CI Query & Widgets Pod All issues related to Query, JS, Eval, and Widgets Table Widget V2 Issues related to Table Widget V2 Task A simple Todo Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature flag to control visibility of this feature(Infinite scrolling).
2 participants