mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Fixed subtitle error being sticky
closes https://linear.app/tryghost/issue/MOM-182 - we were seeing some odd behaviour with the validation engine when validating individual properties that meant our tracked property wasn't auto-updating on subtitle change after a body edit/autosave event - switched to a manually tracked property that's updated based on the validate call status
This commit is contained in:
parent
77afd0a47e
commit
a8342e153e
1 changed files with 15 additions and 6 deletions
|
@ -26,6 +26,7 @@ import {isHostLimitError, isServerUnreachableError, isVersionMismatchError} from
|
||||||
import {isInvalidError} from 'ember-ajax/errors';
|
import {isInvalidError} from 'ember-ajax/errors';
|
||||||
import {mobiledocToLexical} from '@tryghost/kg-converters';
|
import {mobiledocToLexical} from '@tryghost/kg-converters';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
|
import {tracked} from '@glimmer/tracking';
|
||||||
|
|
||||||
const DEFAULT_TITLE = '(Untitled)';
|
const DEFAULT_TITLE = '(Untitled)';
|
||||||
// suffix that is applied to the title of a post when it has been duplicated
|
// suffix that is applied to the title of a post when it has been duplicated
|
||||||
|
@ -158,6 +159,8 @@ export default class LexicalEditorController extends Controller {
|
||||||
|
|
||||||
@inject config;
|
@inject config;
|
||||||
|
|
||||||
|
@tracked excerptErrorMessage = '';
|
||||||
|
|
||||||
/* public properties -----------------------------------------------------*/
|
/* public properties -----------------------------------------------------*/
|
||||||
|
|
||||||
shouldFocusTitle = false;
|
shouldFocusTitle = false;
|
||||||
|
@ -299,13 +302,19 @@ export default class LexicalEditorController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updateExcerpt(excerpt) {
|
async updateExcerpt(excerpt) {
|
||||||
this.post.customExcerpt = excerpt;
|
this.post.customExcerpt = excerpt;
|
||||||
this.post.validate({property: 'customExcerpt'});
|
try {
|
||||||
}
|
await this.post.validate({property: 'customExcerpt'});
|
||||||
|
this.excerptErrorMessage = '';
|
||||||
get excerptErrorMessage() {
|
} catch (e) {
|
||||||
return this.post.errors.errorsFor('customExcerpt')?.[0]?.message;
|
// validator throws undefined on validation error
|
||||||
|
if (e === undefined) {
|
||||||
|
this.excerptErrorMessage = this.post.errors.errorsFor('customExcerpt')?.[0]?.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// updates local willPublish/Schedule values, does not get applied to
|
// updates local willPublish/Schedule values, does not get applied to
|
||||||
|
|
Loading…
Add table
Reference in a new issue