-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Fix "Save changes?" modal saves the options after selecting the 'Discard' option #36160
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
Conversation
Test Results SummaryCommit SHA: 6457489
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
fb3c3fc to
6457489
Compare
ilyasfoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and adding e2e tests, @chihsuan! Excellent work, I have a question to pick your brain but LGTM! 🚢
| let selected = profileItems.industry || []; | ||
|
|
||
| let selected = Array.isArray( profileItems.industry ) | ||
| ? [ ...profileItems.industry ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, why do we need to clone the value here? Is there an issue to reuse the same object reference? Or are there cases where it's not truly an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's the same object reference issue.
Previously, we used the same object in the local state; when we update the local "selected" state, it persists the changes in the global profileItems. So when a user discards the changes and navigates back from a different screen, the user would still see the "changed" view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant, thanks!
rjchow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tests! 😄
…ard' option (#36160) * Tweak save change modal padding * Fix obw save change and add e2e tests * Add changelog * Fix product_types step
All Submissions:
Changes proposed in this Pull Request:
Closes #35934
"Save changes?" modal saves the options after selecting the 'Discard' option because we mutate the value of the profiler items prop.
Changes in this PR:
Before:
After:
How to test the changes in this Pull Request:
Other information:
pnpm --filter=<project> changelog add?FOR PR REVIEWER ONLY: