Skip to content

Commit 52c168d

Browse files
annemirasoldaledupreez
authored andcommitted
Fix buggy unsaved changes warning (#4407)
* Fix 'unsaved changes' warning by adding necessary class to save button * Remove redundant code for warning against unsaved changes * Add changelog and readme entries * Fix behavior for when customizing payment methods * Add comments --------- Co-authored-by: daledupreez <[email protected]>
1 parent dbbc0ec commit 52c168d

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Fix - Ensure that we migrate payment_request_button_size=medium on upgrade
88
* Fix - Show correct price in express checkout for zero decimal currencies
99
* Fix - Fixes a possible fatal error with Multibanco purchases when generating the email instructions.
10+
* Fix - Fix buggy unsaved changes warning in settings page
1011

1112
= 9.5.2 - 2025-05-22 =
1213
* Add - Implement custom database cache for persistent caching with in-memory optimization.

client/settings/general-settings-section/customize-payment-method.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ const CustomizePaymentMethod = ( { method, onClose } ) => {
9494
) }
9595
/>
9696
) }
97-
<ButtonWrapper>
97+
{ /* The 'submit' class is used by WC core to clear unsaved changes warnings.
98+
See https://github.com/woocommerce/woocommerce/blob/fc7ffce309662758c0d3383de8cc8e8c6a57a167/plugins/woocommerce/client/legacy/js/admin/settings.js#L139 */ }
99+
<ButtonWrapper className="submit">
98100
<Button
99101
variant="tertiary"
100102
disabled={ isCustomizing }

client/settings/save-settings-section/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const SaveSettingsSection = ( { onSettingsSave } ) => {
2020
};
2121

2222
return (
23-
<SaveSettingsSectionWrapper>
23+
// The 'submit' class is used by WC core to clear unsaved changes warnings.
24+
// See https://github.com/woocommerce/woocommerce/blob/fc7ffce309662758c0d3383de8cc8e8c6a57a167/plugins/woocommerce/client/legacy/js/admin/settings.js#L139
25+
<SaveSettingsSectionWrapper className="submit">
2426
<Button
2527
isPrimary
2628
isBusy={ isSaving }

client/settings/settings-manager/index.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import React, { useState } from 'react';
44
import { TabPanel } from '@wordpress/components';
55
import { getQuery, updateQueryString } from '@woocommerce/navigation';
66
import styled from '@emotion/styled';
7-
import { isEmpty, isEqual } from 'lodash';
7+
import { isEmpty } from 'lodash';
88
import SettingsLayout from '../settings-layout';
99
import PaymentSettingsPanel from '../payment-settings';
1010
import PaymentMethodsPanel from '../payment-methods';
1111
import SaveSettingsSection from '../save-settings-section';
1212
import { useSettings } from '../../data';
13-
import useConfirmNavigation from 'utils/use-confirm-navigation';
1413

1514
const StyledTabPanel = styled( TabPanel )`
1615
.components-tab-panel__tabs {
@@ -51,18 +50,6 @@ const SettingsManager = () => {
5150
} );
5251
};
5352

54-
const isPristine =
55-
! isEmpty( initialSettings ) && isEqual( initialSettings, settings );
56-
const displayPrompt = ! isPristine;
57-
const confirmationNavigationCallback = useConfirmNavigation(
58-
displayPrompt
59-
);
60-
61-
useEffect( confirmationNavigationCallback, [
62-
displayPrompt,
63-
confirmationNavigationCallback,
64-
] );
65-
6653
// This grabs the "panel" URL query string value to allow for opening a specific tab.
6754
const { panel } = getQuery();
6855

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
118118
* Fix - Ensure that we migrate payment_request_button_size=medium on upgrade
119119
* Fix - Show correct price in express checkout for zero decimal currencies
120120
* Fix - Fixes a possible fatal error with Multibanco purchases when generating the email instructions.
121+
* Fix - Fix buggy unsaved changes warning in settings page
121122

122123
[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

0 commit comments

Comments
 (0)