Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
🐛 Reset publish date in PSM when leaving menu (#708)
Browse files Browse the repository at this point in the history
closes TryGhost/Ghost#8360
- when changing the publish time of an already scheduled post in the publish menu and leaving the menu with clicking outside of the menu, the time wouldn't reset properly and be shown in the PSM. With the usage of an `isClosing` property which is passed to the underlying `gh-publishmenu-scheduling` component, we prevent the changed time from being saved and reset it properly instead.
  • Loading branch information
aileen authored and kevinansfield committed May 23, 2017
1 parent 83081b4 commit 6e84106
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/components/gh-publishmenu-scheduled.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default Component.extend({

post: null,
saveType: null,
isClosing: null,

// used to set minDate in datepicker
_minDate: null,
Expand Down Expand Up @@ -60,8 +61,10 @@ export default Component.extend({
setTime(time) {
let post = this.get('post');

post.set('publishedAtBlogTime', time);
return post.validate();
if (!this.get('isClosing')) {
post.set('publishedAtBlogTime', time);
return post.validate();
}
}
}
});
6 changes: 6 additions & 0 deletions app/components/gh-publishmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export default Component.extend({

_publishedAtBlogTZ: null,

isClosing: null,

forcePublishedMenu: reads('post.pastScheduledTime'),

postState: computed('post.{isPublished,isScheduled}', 'forcePublishedMenu', function () {
Expand Down Expand Up @@ -91,6 +93,7 @@ export default Component.extend({

open() {
this._cachePublishedAtBlogTZ();
this.set('isClosing', false);
this.get('post.errors').clear();
if (this.get('onOpen')) {
this.get('onOpen')();
Expand All @@ -113,6 +116,9 @@ export default Component.extend({
if (this.get('onClose')) {
this.get('onClose')();
}

this.set('isClosing', true);

return true;
}
}
Expand Down
1 change: 1 addition & 0 deletions app/templates/components/gh-publishmenu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{{gh-publishmenu-scheduled
post=post
saveType=saveType
isClosing=isClosing
setSaveType=(action "setSaveType")}}

{{else}}
Expand Down

0 comments on commit 6e84106

Please sign in to comment.