FIX: Do not incorrectly add topic bookmark on Escape (#10088)

* 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.
This commit is contained in:
Martin Brennan 2020-06-19 11:17:18 +10:00 committed by GitHub
parent 5faf074e61
commit b5495b8e9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -430,8 +430,11 @@ const Topic = RestModel.extend({
return this.firstPost().then(firstPost => { return this.firstPost().then(firstPost => {
const toggleBookmarkOnServer = () => { const toggleBookmarkOnServer = () => {
if (bookmark) { if (bookmark) {
return firstPost.toggleBookmark().then(() => { return firstPost.toggleBookmark().then(opts => {
this.set("bookmarking", false); this.set("bookmarking", false);
if (opts.closedWithoutSaving) {
return;
}
return this.afterTopicBookmarked(firstPost); return this.afterTopicBookmarked(firstPost);
}); });
} else { } else {

View File

@ -9,7 +9,7 @@
{{/if}} {{/if}}
<div class="control-group bookmark-name-wrap"> <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"}} {{d-button icon="cog" action=(action "toggleOptionsPanel") class="bookmark-options-button"}}
</div> </div>