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:
parent
735f6eb66f
commit
c3b8fe6b43
2 changed files with 18 additions and 3 deletions
|
@ -116,7 +116,17 @@ export default Controller.extend({
|
||||||
}),
|
}),
|
||||||
|
|
||||||
_saveMemberProperty(propKey, newValue) {
|
_saveMemberProperty(propKey, newValue) {
|
||||||
let member = this.member;
|
let currentValue = this.member.get(propKey);
|
||||||
member.set(propKey, newValue);
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -114,6 +114,11 @@ export default Controller.extend({
|
||||||
newValue = newValue.trim();
|
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
|
// Quit if there was no change
|
||||||
if (newValue === currentValue) {
|
if (newValue === currentValue) {
|
||||||
return;
|
return;
|
||||||
|
@ -122,7 +127,7 @@ export default Controller.extend({
|
||||||
tag.set(propKey, newValue);
|
tag.set(propKey, newValue);
|
||||||
|
|
||||||
// Generate slug based on name for new tag when empty
|
// 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);
|
let slugValue = slugify(newValue);
|
||||||
if (/^#/.test(newValue)) {
|
if (/^#/.test(newValue)) {
|
||||||
slugValue = 'hash-' + slugValue;
|
slugValue = 'hash-' + slugValue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue