appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

fix: Prevent Errors in Debugger When Deleting List Widget

Open jacquesikot opened this issue 1 year ago • 5 comments

Description

Problem When deleting a List widget in the EE environment, the widget is successfully removed, but errors are displayed in the in-app debugger. These errors disappear upon refreshing the page, leaving users confused as to why the errors appeared in the first place, despite the widget being deleted correctly.

Root Cause

  • The issue arises from the sequence in which widgets and their associated meta widgets are deleted.

  • When deleting a widget with meta widgets (e.g., a List widget):

    • The main widget is removed first via the deleteWidget saga.

    • Meta widgets are then deleted later during the componentWillUnmount lifecycle method.

  • The lint evaluation runs between these two processes, detecting meta widgets still present in the state without a parent widget.

  • This mismatch triggers errors in the in-app debugger, which disappear once the page is refreshed, as the meta widgets have already been deleted by then.

Solution

  • We have modified the deletion process to ensure that both the main widget and its associated meta widgets are removed within the same action.

  • Instead of handling meta widget deletion in the general deleteSaga:

    • We now check for widgets with the hasMetaWidgets flag within the deleteWidget saga.

    • If such widgets are found, their meta widgets are deleted before the main widget is removed from the layout.

  • This adjustment ensures that the lint evaluation occurs after both the main widget and its meta widgets have been removed, preventing errors in the debugger.

Fixes #35628

Automation

/ok-to-test tags="@tag.Widget, @tag.List, @tag.IDE, @tag.Sanity"

:mag: Cypress test results

[!TIP] 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10578005558 Commit: 06e65497920398dcf555401ed0f71d14b8e1474d Cypress dashboard. Tags: @tag.Widget, @tag.List, @tag.IDE, @tag.Sanity Spec:


Tue, 27 Aug 2024 13:43:27 UTC

Communication

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

  • [ ] Yes
  • [ ] No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced testing for the list widget to include verification of the drag, drop, and delete functionalities.
    • Improved widget deletion process by ensuring related meta widgets are also addressed during deletion.
    • Updated test descriptions for better clarity and scope, specifically focusing on deletion functionality.
  • Bug Fixes

    • Expanded test coverage for potential issues in widget behavior, particularly concerning deletion.

jacquesikot avatar Aug 21 '24 12:08 jacquesikot

Walkthrough

The recent changes enhance the testing and deletion functionalities of the list widget within the application. The modifications expand the Cypress test cases to include deletion alongside drag-and-drop actions, while also refining the widget deletion saga to effectively manage associated meta widgets. These enhancements aim to ensure a smoother user experience and strengthen the integrity of widget lifecycle management.

Changes

Files Change Summary
app/client/cypress/e2e/Regression/ClientSide/Widgets/ListV2/Listv2_BasicClientSideData_spec.js Updated test descriptions to reflect deletion functionality; added assertions to confirm deletion without error.
app/client/src/sagas/WidgetDeletionSagas.ts Introduced a conditional check for associated meta widgets during deletion, enhancing the saga's robustness.
app/client/src/sagas/WidgetDeleteSagaTestFixtures.ts Added test fixtures for widget deletion, including configurations for selected widgets and updated DSL states.
app/client/src/sagas/WidgetDeletionSaga.test.ts Created unit tests for the deleteSaga function to validate widget deletion and associated actions.

Assessment against linked issues

Objective Addressed Explanation
No error should pop up in the debugger on dropping or deleting the widget. (#35628)

Possibly related issues

  • #33981: The enhancements to the widget deletion saga and associated tests may relate to broader testing for drag-and-drop functionalities in the application.

Poem

In the realm of widgets, they dance and play,
A drag, a drop, and deletion's ballet.
Tests now shine, covering each twist,
Guarding against errors that once could persist.
With meta in check, and sagas refined,
A seamless experience we all designed! 🎉


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

coderabbitai[bot] avatar Aug 21 '24 12:08 coderabbitai[bot]

@jacquesikot there is test case failure. Please check.

sagar-qa007 avatar Aug 22 '24 04:08 sagar-qa007

/build-deploy-preview skip-tests=true

jacquesikot avatar Aug 28 '24 08:08 jacquesikot

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

github-actions[bot] avatar Aug 28 '24 08:08 github-actions[bot]

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

github-actions[bot] avatar Aug 28 '24 08:08 github-actions[bot]