From 0fb2e4e83eae820005e5de58fc2cc4340499829a Mon Sep 17 00:00:00 2001 From: "andy.lee" Date: Mon, 29 Apr 2024 14:26:06 +0800 Subject: [PATCH] fix: reset changedSettings after press save --- src/routes/setting/index.js | 10 +++++++++- src/routes/setting/setting.js | 5 ++++- src/routes/setting/setting.less | 4 ---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/routes/setting/index.js b/src/routes/setting/index.js index a87bfcf1d..376417024 100644 --- a/src/routes/setting/index.js +++ b/src/routes/setting/index.js @@ -28,7 +28,7 @@ class Setting extends React.Component { const { confirmedNavigation, changedSettings } = this.state const isDirty = Object.keys(changedSettings).length > 0 - if (nextLocation.pathname !== '/settings' && isDirty && !confirmedNavigation) { + if (isDirty && !confirmedNavigation) { this.showModal(nextLocation) return false // disallow navigation } @@ -72,6 +72,13 @@ class Setting extends React.Component { } } + resetChangedSettings = () => { + this.setState({ + ...this.state, + changedSettings: {}, + }) + } + render() { const { setting, dispatch, loading } = this.props const { modalVisible, changedSettings } = this.state @@ -87,6 +94,7 @@ class Setting extends React.Component { payload, }) }, + resetChangedSettings: this.resetChangedSettings, onInputChange: this.onInputChange, } diff --git a/src/routes/setting/setting.js b/src/routes/setting/setting.js index 2e69e6fa1..67e16095d 100644 --- a/src/routes/setting/setting.js +++ b/src/routes/setting/setting.js @@ -17,11 +17,13 @@ const form = ({ loading, onSubmit, onInputChange, + resetChangedSettings, }) => { const handleOnSubmit = () => { const fields = getFieldsValue() Object.keys(fields).forEach(key => { fields[key] = fields[key].toString() }) onSubmit(fields) + resetChangedSettings() } const parseSettingRules = (setting) => { const definition = setting.definition @@ -147,7 +149,7 @@ const form = ({ )) return ( - +
{settings}
@@ -174,6 +176,7 @@ form.propTypes = { saving: PropTypes.bool, loading: PropTypes.bool, onInputChange: PropTypes.func, + resetChangedSettings: PropTypes.func, } export default Form.create()(form) diff --git a/src/routes/setting/setting.less b/src/routes/setting/setting.less index 7497bff44..26845d2c6 100644 --- a/src/routes/setting/setting.less +++ b/src/routes/setting/setting.less @@ -28,7 +28,3 @@ border: 1px solid #f15354; } } - -:global .ant-spin-nested-loading{ - height: 100vh; -}