Skip to content

Commit 619647f

Browse files
committed
Saves post title on focus blur if status is draft
Closes #6656 - adds an action to update the title - checks if the post title has changed and is a draft and sends a silent + background save action - includes the action on the focus-out event on the post title
1 parent 0fd5cea commit 619647f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

core/client/app/mixins/editor-base-controller.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,25 @@ export default Mixin.create({
398398
return transition.retry();
399399
},
400400

401+
updateTitle() {
402+
let currentTitle = this.model.get('title');
403+
let newTitle = this.model.get('titleScratch').trim();
404+
405+
if (currentTitle === newTitle) {
406+
return;
407+
}
408+
409+
if (this.get('model.isDraft') && !this.get('model.isNew')) {
410+
// this is preferrable to setting hasDirtyAttributes to false manually
411+
this.model.set('title', newTitle);
412+
413+
this.send('save', {
414+
silent: true,
415+
backgroundSave: true
416+
});
417+
}
418+
},
419+
401420
toggleReAuthenticateModal() {
402421
this.toggleProperty('showReAuthenticateModal');
403422
}

core/client/app/templates/editor/edit.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<section class="gh-view">
22
<header class="view-header">
33
{{#gh-view-title classNames="gh-editor-title" openMobileMenu="openMobileMenu"}}
4-
{{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=model.titleScratch tabindex="1" focus=shouldFocusTitle}}
4+
{{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=model.titleScratch tabindex="1" focus=shouldFocusTitle focus-out="updateTitle" }}
55
{{/gh-view-title}}
66
<section class="view-actions">
77
<button type="button" class="post-settings" title="Post Settings" {{action "openSettingsMenu"}}>

0 commit comments

Comments
 (0)