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

Add default to onDiscard in UnsavedChangesModal #21756

Merged

Conversation

igorschoester
Copy link
Member

@igorschoester igorschoester commented Oct 28, 2024

Context

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where a React prop type warning would occur in the First time configuration, due to the interface of the useBlocker hook.

Relevant technical choices:

Add default to onDiscard in UnsavedChangesModal
While not necessarily useful without, it is easier to work with like this.
Mostly because the useBlocker from react-router-dom has undefined for the reset and proceed functions unless actively blocking.
We could rewrite the usage there to force not rendering this depending on the state. But that is what the isOpen is supposed to be for already.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Enable debug output (SCRIPT_DEBUG)
  • Visit Yoast > General > FTC
  • Verify the warning in the browser console is no longer there

Warning: Failed prop type: The prop onDiscard is marked as required in UnsavedChangesModal, but its value is undefined.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • Regression test going away from the FTC with unsaved changes
    • We should get the modals confirming that we want to move away from the FTC and we should also confirm that dismissing those modals works as expected.
  • Regression test discarding changes in the settings page
    • We should get the modals confirming that we want to discard changes and we should also confirm that dismissing those modals works as expected.

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #21728

@igorschoester igorschoester added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Oct 28, 2024
While not necessarily useful without, it is easier to work with like this.
Mostly because the useBlocker from react-router-dom has undefined for the reset and proceed functions unless actively blocking.
We could rewrite the usage there to force not rendering this depending on the state. But that is what the isOpen is supposed to be for already.
@igorschoester igorschoester force-pushed the 21728-new-general-page-ftc-tab-gives-react-warning branch from 2e552e7 to 30f0716 Compare October 28, 2024 11:59
} );

describe( "fallback props", () => {
it( "should not throw an error when the onClose and onDiscard props are not passed", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

A bit weird because it does not throw, it logs.

This tests the original issue. That the React warning is gone when not passing onClose or onDiscard.
Try to put the isRequired back on them to see if it then fails.

@coveralls
Copy link

coveralls commented Oct 28, 2024

Pull Request Test Coverage Report for Build 04401d5eb85e3c9040ca6a99c1ca7597fcedf2b6

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 54.575%

Totals Coverage Status
Change from base Build 770c2d5b44bd927478799077a816eaadc1541dcf: 0.003%
Covered Lines: 29661
Relevant Lines: 54627

💛 - Coveralls

@pls78
Copy link
Member

pls78 commented Oct 30, 2024

CR: ✅

Copy link
Contributor

@leonidasmi leonidasmi left a comment

Choose a reason for hiding this comment

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

Acceptance test is ✅

@leonidasmi leonidasmi added this to the 23.9 milestone Oct 31, 2024
@leonidasmi leonidasmi merged commit 4f10b4a into trunk Oct 31, 2024
16 checks passed
@leonidasmi leonidasmi deleted the 21728-new-general-page-ftc-tab-gives-react-warning branch October 31, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New general page: FTC tab gives React warning
4 participants