0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed unsaved changes modal showing after focus/blur of tag and member fields

no issue

- the inputs in tag/member settings are now two-way bound which means that a `null` or `undefined` value can become `""` when a field is focused/blurred due to inputs only working on strings
- if a `null` or `undefined` property value becomes `""` Ember Data will treat that as a dirty property and that will in turn trigger the unsaved changes modal when leaving the tag/member details screens
- this change strengthens our `_saveXProperty` private controller methods to skip any changes between "falsy" property values unless the new value is explicitly `false`
This commit is contained in:
Kevin Ansfield 2019-12-16 17:01:51 +00:00
parent 735f6eb66f
commit c3b8fe6b43
2 changed files with 18 additions and 3 deletions

View file

@ -116,7 +116,17 @@ export default Controller.extend({
}),
_saveMemberProperty(propKey, newValue) {
let member = this.member;
member.set(propKey, newValue);
let currentValue = this.member.get(propKey);
if (newValue) {
newValue = newValue.trim();
}
// avoid modifying empty values and triggering inadvertant unsaved changes modals
if (newValue !== false && !newValue && !currentValue) {
return;
}
this.member.set(propKey, newValue);
}
});

View file

@ -114,6 +114,11 @@ export default Controller.extend({
newValue = newValue.trim();
}
// avoid modifying empty values and triggering inadvertant unsaved changes modals
if (newValue !== false && !newValue && !currentValue) {
return;
}
// Quit if there was no change
if (newValue === currentValue) {
return;
@ -122,7 +127,7 @@ export default Controller.extend({
tag.set(propKey, newValue);
// Generate slug based on name for new tag when empty
if (propKey === 'name' && !tag.get('slug') && tag.isNew) {
if (propKey === 'name' && !tag.slug && tag.isNew) {
let slugValue = slugify(newValue);
if (/^#/.test(newValue)) {
slugValue = 'hash-' + slugValue;