0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

🐛 Fixed issue with settings being marked as dirty when visibility is changed (#18370)

refs https://github.com/TryGhost/Product/issues/3924

Settings were being marked as dirty when visibility was changed causing
the confirm dialog to show when navigating away from the settings page.
This change manually computes the dirtiness of the setting to ensure the
visibility change is ignored
This commit is contained in:
Michael Barrett 2023-09-27 08:18:21 +01:00 committed by GitHub
parent 7bebe7daf4
commit 497f3b40dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -100,6 +100,16 @@ export default class CustomThemeSettingsServices extends Service {
updateSettingsVisibility() {
this.settings.forEach((setting) => {
setting.visible = this._isSettingVisible(setting);
// Updating the setting visibility will cause the setting to be marked as dirty so
// we need to compute whether the setting is actually dirty and set the flag manually
const changedProperties = Object.keys(setting.changedAttributes()).filter(key => key !== 'visible');
setting.hasDirtyAttributes = false;
if (changedProperties.length > 0) {
setting.hasDirtyAttributes = true;
}
});
}