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

LYS - Disable the save changes button until changes are made #47316

Merged

Conversation

moon0326
Copy link
Contributor

@moon0326 moon0326 commented May 9, 2024

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:

  1. Create a new JN site with this branch.
  2. Go to WooCommerce -> Settings -> Site Visibility
  3. Confirm the Save changes button is in disabled state.
  4. Make changes.
  5. Confirm the button changes to enabled.
  6. Make changes back to the original.
  7. Confirm the button is back to disabled state.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

LYS: disables the "Save changes" button until changes are made.

Comment

@moon0326 moon0326 requested review from a team, adrianduffell and rjchow May 9, 2024 12:23
Copy link
Contributor

github-actions bot commented May 9, 2024

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:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

github-actions bot commented May 9, 2024

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

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.

@moon0326 moon0326 closed this May 9, 2024
@moon0326 moon0326 reopened this May 9, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label May 9, 2024
@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

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

🤭

Copy link
Contributor Author

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',
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

@moon0326 moon0326 May 10, 2024

Choose a reason for hiding this comment

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

$request = new WP_REST_Request( 'POST', $this->endpoint . '/activate' );
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
Copy link
Contributor

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

Copy link
Contributor Author

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 👍

@moon0326 moon0326 force-pushed the update/47304-disable-save-button-until-changes-are-made branch from a784cbc to b8990c3 Compare May 10, 2024 15:30
Copy link
Contributor

@rjchow rjchow left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

Copy link
Member

@chihsuan chihsuan left a 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';
Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chihsuan TIL! Replaced it with simple === instead in 6e72292

@adrianduffell
Copy link
Contributor

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.

I've now created a follow-up issue for this #47393.

@moon0326 moon0326 merged commit 5183b1b into trunk May 13, 2024
24 of 25 checks passed
@moon0326 moon0326 deleted the update/47304-disable-save-button-until-changes-are-made branch May 13, 2024 14:56
@github-actions github-actions bot added this to the 9.0.0 milestone May 13, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label May 13, 2024
@nigeljamesstevenson nigeljamesstevenson added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable save button until changes are made
6 participants