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

fix: JSONForm select/multiselect filterText value synchronous update with onFilterUpdate action #12578

Merged
merged 3 commits into from
Apr 8, 2022

Conversation

ashit-rath
Copy link
Contributor

@ashit-rath ashit-rath commented Apr 5, 2022

Description

For a serverside enabled select/multiselect field type when an onFilterUpdate action is added, and within that action if the select/multiselect field's filterText property ({{fieldState.select.filterText}}) is used, when the action is trigger the action' function does not get the latest value of the filterText.

Fixes #12545

Steps

  1. Drop a JSONForm
  2. Convert a field to select type
  3. Enable Filterable and Server Side Filtering
  4. Enable JS binding for onFilterUpdate
  5. Add the following binding {{showAlert('Filter update:'}}{{fieldState?.<fieldName>?.filterText)}} (make sure to modify the fieldName)
  6. Type in the input of the select menu, the alert will always show the previous value.

Problem:
The update to the filterText always happened after the action was executed (the after update hook for updating meta was not being used).

Fix:
Refactored the code to make the update of filterText in sync with the tigger of the action.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Manual
  • Cypress

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Test coverage results 🧪

⚪ Total coverage has not changed
// Code coverage diff between base branch:release and head branch: fix/12545-jsonform-filter-text 
Status File % Stmts % Branch % Funcs % Lines
🟢 total 56.35 (0.01) 37.8 (0) 35.96 (0) 56.57 (-0.01)
🔴 app/client/src/utils/autocomplete/TernServer.ts 52.71 (-0.23) 40.83 (-0.84) 36.21 (0) 56.74 (-0.25)
🔴 app/client/src/widgets/JSONFormWidget/schemaParser.ts 98.17 (0) 89.7 (-0.6) 100 (0) 98.74 (0)
🟢 app/client/src/widgets/JSONFormWidget/fields/MultiSelectField.tsx 28.77 (1.5) 5.41 (0) 0 (0) 33.33 (0.52)
🟢 app/client/src/widgets/JSONFormWidget/fields/SelectField.tsx 30.36 (1.05) 4.55 (0) 0 (0) 32.69 (0.61)
🔴 app/client/src/widgets/JSONFormWidget/fields/useUpdateInternalMetaState.ts 35.29 (-0.42) 0 (0) 0 (0) 35.29 (-0.42)
🟢 app/client/src/widgets/JSONFormWidget/widget/helper.ts 98.92 (0.01) 90.91 (0.43) 100 (0) 98.82 (0)
🔴 app/client/src/widgets/JSONFormWidget/widget/index.tsx 30.1 (0.29) 0 (0) 21.43 (-0.79) 30.61 (-1.3)

@vercel
Copy link

vercel bot commented Apr 5, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/get-appsmith/appsmith/AHNQx1brRigMusnjTi4LJKJXbsnU
✅ Preview: https://appsmith-git-fix-12545-jsonform-filter-text-get-appsmith.vercel.app

@github-actions github-actions bot added Widgets Product This label groups issues related to widgets Bug Something isn't working High This issue blocks a user from building or impacts a lot of users JSON Form Issue / features related to the JSON form wiget UI Building Pod labels Apr 5, 2022
@ashit-rath
Copy link
Contributor Author

/ok-to-test sha=d30740e

@github-actions
Copy link

github-actions bot commented Apr 5, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2094685892.
Workflow: Appsmith External Integration Test Workflow.
Commit: d30740e.
PR: 12578.

@ashit-rath ashit-rath changed the title fix: JSONForm select/multiselect filterText synchronous update with onFilterUpdate action fix: JSONForm select/multiselect filterText value synchronous update with onFilterUpdate action Apr 5, 2022
@github-actions
Copy link

github-actions bot commented Apr 5, 2022

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2094685892.
Commit: d30740e.
Results:

Click to view performance test results

Median Mean SD.Sample SD.Population

sbalaji1192
sbalaji1192 previously approved these changes Apr 5, 2022

const debouncedUpdateProperty = useMemo(
() => debounce(updateProperty, DEBOUNCE_TIMEOUT),
[setMetaInternalFieldState, updateProperty],
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: we can remove setMetaInternalFieldState from deps, since its a dep of updateProperty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yes!

@sbalaji1192
Copy link
Contributor

sbalaji1192 commented Apr 5, 2022

have triggered the failed jobs to again in CI.

@ashit-rath
Copy link
Contributor Author

/ok-to-test sha=cc67d32

@github-actions
Copy link

github-actions bot commented Apr 6, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2100750608.
Workflow: Appsmith External Integration Test Workflow.
Commit: cc67d32.
PR: 12578.

@chandannkumar
Copy link

chandannkumar commented Apr 6, 2022

Observation:
LOOM DEMO

filterText value shows alert on Page change of applications

@github-actions
Copy link

github-actions bot commented Apr 6, 2022

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2100750608.
Commit: cc67d32.
Results:

Click to view performance test results

Median Mean SD.Sample SD.Population

@ashit-rath
Copy link
Contributor Author

@chandannkumar Can you share the app? I'm unable to reproduce it

@chandannkumar
Copy link

chandannkumar commented Apr 6, 2022

Public app

@ashit-rath

@ashit-rath
Copy link
Contributor Author

@chandannkumar I think it's a problem with the multi-select widget. I don't know if this is intentional or not.
@Tooluloope Can you confirm if this behaviour is valid or a bug with multiselect widget?

@Tooluloope
Copy link
Contributor

@ashit-rath this is definitely a bug

@ashit-rath
Copy link
Contributor Author

ashit-rath commented Apr 7, 2022

@Tooluloope Thanks for the confirmation
@chandannkumar Can you please create an issue for this and do check if select widget also has the same behaviour.

Note: Fixing this in the individual widget would fix the issue in JSONForm as well.

@ashit-rath
Copy link
Contributor Author

/ok-to-test sha=98481e3

@github-actions
Copy link

github-actions bot commented Apr 8, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2113059051.
Workflow: Appsmith External Integration Test Workflow.
Commit: 98481e3.
PR: 12578.

@github-actions
Copy link

github-actions bot commented Apr 8, 2022

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2113059051.
Commit: 98481e3.
Results:

Click to view performance test results

Median Mean SD.Sample SD.Population

@chandannkumar
Copy link

Tested this PR and working as expected

@ashit-rath ashit-rath merged commit 99ec9e8 into release Apr 8, 2022
@ashit-rath ashit-rath deleted the fix/12545-jsonform-filter-text branch April 8, 2022 06:09
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 JSON Form Issue / features related to the JSON form wiget Widgets Product This label groups issues related to widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: JSON form (Select field): filterText property is not evaluated properly
4 participants