-
Notifications
You must be signed in to change notification settings - Fork 69
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 settings rendering on the Advanced Fraud Protection page #9521
Fix settings rendering on the Advanced Fraud Protection page #9521
Conversation
…tion settings page This mechanism was a hacky way of promoting a re-render in the page, and making the data immutable should make it unnecessary.
…e of truth Additionally, remove the code that could potentially make the page less reliable by directly changing the object without considering immutability concerns.
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: -89 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
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 taking care of this, the code is more readable now without the useEffects, and less prone to errors. I prefer how you implemented the handleInputChange
methods to be reusable and remove boilerplate code.
It works as expected, let's 🚢 it!
const minItems = parseInt( settingUI?.min_items + '', 10 ); | ||
const maxItems = parseInt( settingUI?.max_items + '', 10 ); |
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.
Not related to the PR, just out of curiosity, wouldn't be better to use Number
here? It will remove the need to cast to string and use a radix.
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, I think it would be better to use Number
here instead of the multiple parseInt
, but I'd be more comfortable having it in a different PR. I can open an enhancement issue to address that. It could even be something that we do on cooldown weeks. What do you think?
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.
Yep, definitely something to explore on a cooldown or similar 🙂
Fixes #9520
Fixes #8747
Changes proposed in this Pull Request
This PR aims to fix the Advanced Fraud Protection page that wasn't rendering the settings as expected, which also impacted the confirmation modal before leaving the page.
The approach used was to remove any code that was changing the
protectionSettingsUI
object directly and the globaluseEffects
, to have specifichandleChange
functions for each form field. This makes the code simpler and adds immutability to the protection settings data.Testing instructions
Before checking out to this branch:
develop
and also update itgit pull
npm run start
Test this branch
npm run start
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge