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
LYS - Disable the save changes button until changes are made #47316
LYS - Disable the save changes button until changes are made #47316
Conversation
Hi @adrianduffell, @rjchow, @woocommerce/ghidorah Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
@@ -111,6 +110,7 @@ public function test_activate_plugin() { | |||
$response = $this->server->dispatch( $request ); | |||
$data = $response->get_data(); | |||
$active_plugins = Plugins::get_active_plugins(); | |||
var_dump($data); |
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.
🤭
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.
@psealock Thank you for catching it 😄 Removed it in Remove test code 🙏
const initValues = { | ||
comingSoon: setting.woocommerce_coming_soon, | ||
storePagesOnly: | ||
setting.woocommerce_store_pages_only === false ? 'no' : 'yes', |
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 think this checking for === false
is causing the save button to be disabled only when all the values are 'yes', so it's not actually disabling the save button for any other combination of values
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.
@rjchow Thanks! I'll re-test it.
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.
@rjchow Fixed in Fix incorrect comparison
$request = new WP_REST_Request( 'POST', $this->endpoint . '/activate' ); | ||
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
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.
is this for fixing this test failure? #47337
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.
@rjchow Yeah, good find! I missed that. I'll rebase instead 👍
a784cbc
to
b8990c3
Compare
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.
lgtm, thanks!
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.
Tested well. Left a comment to avoid adding more lodash functions.
Also, I agree with @psealock that the Save button behavior should be consistent across all settings screens. I think we should have a solution that works for all settings screens, not just this one. But that can be a separate task.
} from '@wordpress/element'; | ||
import { registerPlugin } from '@wordpress/plugins'; | ||
import { __ } from '@wordpress/i18n'; | ||
import classNames from 'classnames'; | ||
import { useCopyToClipboard } from '@wordpress/compose'; | ||
import { recordEvent } from '@woocommerce/tracks'; | ||
import { getSetting } from '@woocommerce/settings'; | ||
import { isEqual } from 'lodash'; |
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.
We can replace isEqual
with fastDeepEqual so we don't have to add more lodash functions to our codebase (pdToLP-yS-p2).
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've now created a follow-up issue for this #47393. |
Submission Review Guidelines:
Changes proposed in this Pull Request:
Closes #47304
This PR disables the
Save changes
button until changes are made.How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
WooCommerce -> Settings -> Site Visibility
Save changes
button is in disabled state.Changelog entry
Significance
Type
Message
LYS: disables the "Save changes" button until changes are made.
Comment