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

#9355: fix dirty flag on Formik reinitialization regression #9361

Merged
merged 14 commits into from
Oct 29, 2024

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Oct 26, 2024

What does this PR do?

Discussion

Remaining Work

  • Fix playwright test: for discussion - when a brick configuration useEffect updates the Formik values automatically on mount, do we want that to show as unsaved changes?
    • Long-term the autom-running normalizations should to be moved into the form state adapter
  • Add playwright test

Future Work

For more information on our expectations for the PR process, see the
code review principles doc

@twschiller twschiller self-assigned this Oct 26, 2024
@twschiller twschiller added regression bug Something isn't working labels Oct 26, 2024
@twschiller twschiller added this to the 2.1.6 milestone Oct 26, 2024
Copy link

codecov bot commented Oct 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.44%. Comparing base (8318d74) to head (754b463).
Report is 436 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    pixiebrix/pixiebrix-extension#9361      +/-   ##
==========================================
+ Coverage   74.24%   75.44%   +1.20%     
==========================================
  Files        1332     1386      +54     
  Lines       40817    42043    +1226     
  Branches     7634     7755     +121     
==========================================
+ Hits        30306    31721    +1415     
+ Misses      10511    10322     -189     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Oct 26, 2024

Playwright test results

passed  147 passed
flaky  1 flaky
skipped  2 skipped

Details

report  Open report ↗︎
stats  150 tests across 49 suites
duration  22 minutes, 14 seconds
commit  754b463
info  For more information on how to debug and view this report, see our readme

Flaky tests

chrome › tests/pageEditor/copyMod.spec.ts › run a copied mod with a built-in integration

Skipped tests

chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
msedge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options

@twschiller twschiller marked this pull request as draft October 26, 2024 19:07
@twschiller twschiller changed the title #9355: fix dirty state regression #9355: [WIP] fix dirty state regression Oct 26, 2024
@twschiller twschiller changed the title #9355: [WIP] fix dirty state regression #9355: [WIP] fix dirty flag on Formik reinitialization regression Oct 27, 2024
dispatch(actions.checkActiveModComponentAvailability());
const currentKey = getFormReinitializationKey();

// Don't sync on the first call after the reinitialization key changes because the call would cause
Copy link
Contributor Author

@twschiller twschiller Oct 27, 2024

Choose a reason for hiding this comment

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

See the failing CI test. I think our options are:

  1. Check for deep equality on the first update after reinitialization to determine whether or not the values have actually changed (so normalization would still cause the change icon to appear)
  2. Ignore the initial sync (current behavior of the PR) under the assumption that any normalization should never impact the functionality so there's no reason to show the change icon. (The only gotcha here is that the call is debounced -- so might want to ensure there's no actually human-made changes within the debounce window)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up going with approach 1. With approach 2, there's a corner case where normalizations get overwritten if the user's next change is not via Formik

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Latest changes have a blended approach - it updates the form state but does not update the dirty flag

@twschiller
Copy link
Contributor Author

@grahamlangford re-assigning to you for now because I believe this is related to the reinitialization PR: #9351 and I'll be partially OOO tomorrow

@@ -34,7 +34,7 @@ export const NotAvailableIcon: React.FunctionComponent = () => (
);

export const UnsavedChangesIcon: React.FunctionComponent = () => (
<Icon library="custom" icon="ic-unsaved" />
<Icon library="custom" icon="ic-unsaved" title="Unsaved changes" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These should probably have role="status", but Playwright getByRole didn't seem to be working for that

@twschiller twschiller marked this pull request as ready for review October 28, 2024 20:16
@twschiller twschiller changed the title #9355: [WIP] fix dirty flag on Formik reinitialization regression #9355: fix dirty flag on Formik reinitialization regression Oct 28, 2024
@twschiller twschiller added the do not merge Merging of this PR is blocked by another one label Oct 28, 2024
@twschiller twschiller removed the do not merge Merging of this PR is blocked by another one label Oct 29, 2024
@twschiller twschiller marked this pull request as ready for review October 29, 2024 18:27
Copy link

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@twschiller twschiller merged commit 351e92f into main Oct 29, 2024
23 checks passed
@twschiller twschiller deleted the feature/9355-clear-changes branch October 29, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Mod component shows as unsaved/dirty after clearing changes
2 participants