0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

🐛 Fixed post feature image caption updates saving with every keystroke (#18833)

closes TryGhost/Product#4093
- added proper on blur handling to trigger autosave instead of each update to the caption text
This commit is contained in:
Steve Larson 2023-11-01 17:44:55 -05:00 committed by GitHub
parent 0c972d8276
commit 3f368d05d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 1 deletions

View file

@ -75,7 +75,7 @@
@onChangeHtml={{this.setCaption}}
@placeholderText={{if this.captionInputFocused "" "Add a caption to the feature image"}}
@onFocus={{fn (mut this.captionInputFocused) true}}
@onBlur={{fn (mut this.captionInputFocused) false}}
@onBlur={{this.handleCaptionBlur}}
/>
{{/if}}
<button

View file

@ -39,6 +39,12 @@ export default class GhEditorFeatureImageComponent extends Component {
this.args.updateCaption(cleanedHtml);
}
@action
handleCaptionBlur() {
this.captionInputFocused = false;
this.args.handleCaptionBlur();
}
@action
setUploadedImage(results) {
if (results[0]) {

View file

@ -16,6 +16,7 @@
@updateAlt={{@setFeatureImageAlt}}
@caption={{@featureImageCaption}}
@updateCaption={{@setFeatureImageCaption}}
@handleCaptionBlur={{@handleFeatureImageCaptionBlur}}
@forceButtonDisplay={{or (not @title) (eq @title "(Untitled)") this.titleIsHovered this.titleIsFocused}}
@isHidden={{or (not @cardOptions.post.showTitleAndFeatureImage) false}}
/>

View file

@ -347,7 +347,10 @@ export default class LexicalEditorController extends Controller {
@action
setFeatureImageCaption(html) {
this.post.set('featureImageCaption', html);
}
@action
handleFeatureImageCaptionBlur() {
if (this.post.isDraft) {
this.autosaveTask.perform();
}

View file

@ -82,6 +82,7 @@
@setFeatureImage={{this.setFeatureImage}}
@setFeatureImageAlt={{this.setFeatureImageAlt}}
@setFeatureImageCaption={{this.setFeatureImageCaption}}
@handleFeatureImageCaptionBlur={{this.handleFeatureImageCaptionBlur}}
@clearFeatureImage={{this.clearFeatureImage}}
@cardOptions={{hash
post=this.post