🐛 Fixed incorrect save warning on design settings

closes https://github.com/TryGhost/Ghost/issues/11590

- Dirty attribute flag was set incorrectly on focus out from label/url fields as no check with existing was used
- Checks against existing nav item value before setting dirty attribute on focus out
This commit is contained in:
Rish 2020-06-18 17:36:17 +05:30 committed by Rishabh Garg
parent 29c1b2f18c
commit a7c0899782
4 changed files with 17 additions and 8 deletions

View File

@ -16,10 +16,10 @@
<GhTrimFocusInput
@shouldFocus={{this.navItem.last}}
@placeholder="Label"
@value={{readonly this.navItem.label}}
@input={{action (mut this.navItem.label) value="target.value"}}
@value={{readonly this.label}}
@input={{action (mut this.label) value="target.value"}}
@keyPress={{action "clearLabelErrors"}}
@focus-out={{action "updateLabel" this.navItem.label}} data-test-input="label" />
@focus-out={{action "updateLabel" this.label}} data-test-input="label" />
<GhErrorMessage
@errors={{this.navItem.errors}}
@property="label" data-test-error="label" />
@ -34,7 +34,7 @@
<GhNavitemUrlInput
@baseUrl={{this.baseUrl}}
@isNew={{this.navItem.isNew}}
@url={{readonly this.navItem.url}}
@url={{readonly this.url}}
@update={{action "updateUrl"}}
@clearErrors={{action "clearUrlErrors"}} data-test-input="url" />
<GhErrorMessage

View File

@ -1,5 +1,6 @@
import Component from '@ember/component';
import ValidationState from 'ghost-admin/mixins/validation-state';
import boundOneWay from 'ghost-admin/utils/bound-one-way';
import {computed} from '@ember/object';
import {readOnly} from '@ember/object/computed';
import {run} from '@ember/runloop';
@ -15,6 +16,8 @@ export default Component.extend(ValidationState, {
deleteItem() {},
updateUrl() {},
updateLabel() {},
label: boundOneWay('navItem.label'),
url: boundOneWay('navItem.url'),
errors: readOnly('navItem.errors'),

View File

@ -69,8 +69,10 @@ export default Controller.extend({
return;
}
navItem.set('label', label);
this.set('dirtyAttributes', true);
if (navItem.get('label') !== label) {
navItem.set('label', label);
this.set('dirtyAttributes', true);
}
},
updateUrl(url, navItem) {
@ -78,8 +80,10 @@ export default Controller.extend({
return;
}
navItem.set('url', url);
this.set('dirtyAttributes', true);
if (navItem.get('url') !== url) {
navItem.set('url', url);
this.set('dirtyAttributes', true);
}
return url;
},

View File

@ -38,6 +38,7 @@
@baseUrl={{this.blogUrl}}
@addItem={{action "addNavItem"}}
@updateUrl={{action "updateUrl"}}
@updateLabel={{action "updateLabel"}}
data-test-navitem="new" />
</form>
</div>
@ -64,6 +65,7 @@
@baseUrl={{this.blogUrl}}
@addItem={{action "addNavItem"}}
@updateUrl={{action "updateUrl"}}
@updateLabel={{action "updateLabel"}}
data-test-navitem="new" />
</form>
</div>