fix(#16584): filterTableData source of truth
Description
TL;DR: This PR addresses is related to #16584 where editing a table row with applied filters becomes impossible without clearing the filters
When a filter is applied to the table data, the current behavior results in filter updates without validating or saving the updated value of the row being edited. This leads to a situation where users are unable to save or discard changes until the filters are cleared. The proposed fix ensures that the original row is retrieved from the table data and used in filtering, allowing editing and filtering to work as expected.
Here's a screen record for the solution
Motivation:
The problem arises in scenarios where table rows are editable and filters are applied. This change ensures that users can continue editing table rows without being forced to clear filters first.
Context:
This change is required to improve user experience and fix the broken editing functionality when filters are active. The change ensures that editable values in filtered rows are correctly handled and saved.
Fixes https://www.loom.com/share/335d0c61817646a0903d581adf73064e
Automation
/ok-to-test tags="table-widget,filter,edit"
:mag: Cypress test results
[!CAUTION]
If you modify the content in this section, you are likely to disrupt the CI result for your PR.
Communication
Should the DevRel and Marketing teams inform users about this change?
- [x] Yes
- [ ] No
Summary by CodeRabbit
-
New Features
- Improved filtering accuracy in the TableWidgetV2 by using original row data for evaluations.
-
Bug Fixes
- Enhanced functionality to ensure that filtering conditions are evaluated correctly with original data.
-
Tests
- Added new test cases to validate filtering functionality after edits in the TableWidgetV2.
- Expanded test coverage for checkbox and switch interactions to ensure accurate filtering behavior.
-
Style
- Minor adjustments to comments and formatting for better readability.
Walkthrough
The changes made in this pull request focus on the getFilteredTableData function within the TableWidgetV2 widget. A key modification involves retrieving the original row from props.tableData using the index of the displayed row, ensuring that the filtering logic operates on both the original and displayed data. This adjustment enhances the accuracy of the filtering conditions while maintaining the existing logic. Additionally, new test cases were added to validate the filtering behavior after edits, and test suites for checkbox and switch components were refined for better interaction coverage.
Changes
| File Path | Change Summary |
|---|---|
app/client/src/widgets/TableWidgetV2/widget/derived.js |
Modified getFilteredTableData to retrieve the original row from props.tableData for accurate filtering. |
app/client/src/widgets/TableWidgetV2/widget/derived.test.js |
Added new test cases for getFilteredTableData to validate filtering after edits, enhancing test coverage. |
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/checkboxCell_spec.js |
Enhanced checkbox interaction tests with new assertions and streamlined logic for filtering functionality. |
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/switchCell_spec.js |
Updated switch interaction tests to include new assertions for filtering and interaction with a discard button, improving test robustness. |
Possibly related PRs
-
#36755: This PR enhances the filtering functionality for select column labels, which directly relates to the modifications made in the main PR's
getFilteredTableDatafunction to include both displayed row data and original row data in the filtering logic. - #36061: This PR addresses the search functionality in tables with select column types, ensuring that both label and value are considered during searches, which aligns with the main PR's updates to the filtering logic.
- #35412: This PR addresses functionality issues in the table widget that could indirectly relate to the filtering logic, ensuring that the interactive elements work correctly during filtering.
- #35124: This PR introduces changes to the select column behavior, relevant to the main PR's updates on how filtering should consider label values.
- #34593: This PR modifies the filtering properties of the table widget, impacting the filtering logic in the main PR regarding the visibility and interaction of filters.
Suggested labels
Bug, Enhancement, Widgets Product, High, Production, Needs Triaging, Table Widget V2, ok-to-test, Query & JS Pod, Help enterprise
Suggested reviewers
- ApekshaBhosale
- rahulbarwal
- sagar-qa007
- jacquesikot
🎉 In the world of code, where logic does flow,
A tweak here and there makes the data aglow.
Original rows now guide the filter's keen eye,
Ensuring accuracy, oh my, oh my!
With comments polished and formatting bright,
The TableWidget shines, a beautiful sight! 🌟
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?
🪧 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
Added @rahulbarwal
@anasKhafaga Client lint and prettier check are failing for your changes. Please fix. You can run these commands locally, to ensure there are no issues.
- yarn run lint:ci
- yarn run prettier:ci
@rahulbarwal , Fixed and pushed, could you please re-run the CI
Thanks @anasKhafaga. Some feedback on the solution: https://www.loom.com/share/d26de384c4d146e88708fa29e7f8ff88
@rahulbarwal , Actually, I have paid attention to applying filter via pane, only not searching as I have followed the bug reproduction via the early shared video. But there's no problem. I'll consider the search use case as well.
@rahulbarwal , use case is fixed: https://www.loom.com/share/cddc48ce00594fc09e2fbd79fb41bdf0?sid=d28dd584-f128-4fbd-9423-68686ce71717
@anasKhafaga looks like these changes are making 2 specs fail. Can you please check and fix? https://github.com/appsmithorg/appsmith/actions/runs/11362207134/job/31611489055
@rahulbarwal , I have inspected the failing tests and applied them manually in this record.
https://www.loom.com/share/7df2b094205d472296adb133a851f63d?sid=9050a3fd-39b5-43ae-9861-3a70938f2004 This record tests
releaseenv and dev env which hosts this PR. The two failing test suits expects the old behavior in thereleaseenv and that's why this PR exists(to solve this behavior).
Those test suits evaluates the old behavior which this PR comes to solve. In the third test case of each, cypress finally uncheck the first row without saving the changes. When the 4th test case(which fails) runs it filters the checked records only and expects that the first record to be filtered out and vice versa with filtering unchecked records.
The only way is to update the test cases to suit the new expected behavior but I'll be waiting for your green light to make this update.
The only way is to update the test cases to suit the new expected behavior
Thats right @anasKhafaga
@rahulbarwal , Fixed and pushed, Could you please check the changes and re-run the CI?
Found one edge case, please check it out @anasKhafaga https://www.loom.com/share/b95870e4b9c146999a0bc02aa84821a2
@rahulbarwal , Sorting case is handled and pushed, however I won't be able to run regression tests on my local due to lack of resources so let's check the CI results.
Hey @anasKhafaga This spec is failing: cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_spec.js and I think it is related to changes on this PR, here is the CI run. https://github.com/appsmithorg/appsmith/actions/runs/11496825933/job/32000034459 Can you please check?
There are other failures which are unrelated, so we can ignore those.
@rahulbarwal , Handled and pushed, could you please re-run the CI?
Is PR ready for merging or we still have further steps? @rahulbarwal
Hey @anasKhafaga I think it is ready. There were some unrelated failures in CI. I have re-triggered after taking the latest pull. You can monitor in the description here: https://github.com/appsmithorg/appsmith/pull/36878
Once it passes, we will merge this PR.