mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Protected against quick escapes when loading post
fix https://linear.app/tryghost/issue/SLO-180/typeerror-cannot-read-properties-of-null-reading-displayname - in the event you click on a post and then press Back really quickly, `this.post` will be null because the post is not loaded - the code here fails because it tries to read a property from `null` - we can protect against that by using optional chaining on the property
This commit is contained in:
parent
14cabf97df
commit
0193ad90bb
1 changed files with 3 additions and 3 deletions
|
@ -871,11 +871,11 @@ export default class LexicalEditorController extends Controller {
|
||||||
this.ui.updateDocumentTitle();
|
this.ui.updateDocumentTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// sync the post slug with the post title, except when:
|
// sync the post slug with the post title, except when:
|
||||||
// - the user has already typed a custom slug, which should not be overwritten
|
// - the user has already typed a custom slug, which should not be overwritten
|
||||||
// - the post has been published, so that published URLs are not broken
|
// - the post has been published, so that published URLs are not broken
|
||||||
*/
|
*/
|
||||||
@enqueueTask
|
@enqueueTask
|
||||||
*generateSlugTask() {
|
*generateSlugTask() {
|
||||||
const currentTitle = this.get('post.title');
|
const currentTitle = this.get('post.title');
|
||||||
|
@ -916,7 +916,7 @@ export default class LexicalEditorController extends Controller {
|
||||||
*backgroundLoaderTask() {
|
*backgroundLoaderTask() {
|
||||||
yield this.store.query('snippet', {limit: 'all'});
|
yield this.store.query('snippet', {limit: 'all'});
|
||||||
|
|
||||||
if (this.post.displayName === 'page' && this.feature.get('collections') && this.feature.get('collectionsCard')) {
|
if (this.post?.displayName === 'page' && this.feature.get('collections') && this.feature.get('collectionsCard')) {
|
||||||
yield this.store.query('collection', {limit: 'all'});
|
yield this.store.query('collection', {limit: 'all'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue