Skip to content

Commit

Permalink
FIX: Do not incorrectly add topic bookmark on Escape (#10088)
Browse files Browse the repository at this point in the history
* The first post was showing as bookmarked incorrectly after pressing f to open the topic modal then pressing escape to cancel without saving, because the closeWithoutSaving option was not being respected.
* Also re-introduce the enter shortcut when the name input is focused to saveAndClose the bookmark modal by pressing enter.
  • Loading branch information
martin-brennan committed Jun 19, 2020
1 parent 5faf074 commit b5495b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/assets/javascripts/discourse/app/models/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,11 @@ const Topic = RestModel.extend({
return this.firstPost().then(firstPost => {
const toggleBookmarkOnServer = () => {
if (bookmark) {
return firstPost.toggleBookmark().then(() => {
return firstPost.toggleBookmark().then(opts => {
this.set("bookmarking", false);
if (opts.closedWithoutSaving) {
return;
}
return this.afterTopicBookmarked(firstPost);
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{/if}}

<div class="control-group bookmark-name-wrap">
{{input id="bookmark-name" value=model.name name="bookmark-name" class="bookmark-name" placeholder=(i18n "post.bookmarks.name_placeholder")}}
{{input id="bookmark-name" value=model.name name="bookmark-name" class="bookmark-name" enter=(action "saveAndClose") placeholder=(i18n "post.bookmarks.name_placeholder")}}
{{d-button icon="cog" action=(action "toggleOptionsPanel") class="bookmark-options-button"}}
</div>

Expand Down

0 comments on commit b5495b8

Please sign in to comment.