DEV: allow composer option to skip jumping to a post on save (#14675)

* DEV: allow composer option to skip jumping to a post on save

* DEV: refactor js safe access in jump logic

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Jeff Wong 2021-10-21 10:46:04 -10:00 committed by GitHub
parent 61a7fbdd9e
commit 6192189fd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -632,7 +632,9 @@ export default Controller.extend({
},
save(ignore, event) {
this.save(false, { jump: !(event && event.shiftKey) });
this.save(false, {
jump: !event?.shiftKey && !this.skipJumpOnSave,
});
},
displayEditReason() {
@ -956,6 +958,7 @@ export default Controller.extend({
@param {Number} [opts.prioritizedCategoryId]
@param {String} [opts.draftSequence]
@param {Boolean} [opts.skipDraftCheck]
@param {Boolean} [opts.skipJumpOnSave] Option to skip navigating to the post when saved in this composer session
**/
open(opts) {
opts = opts || {};
@ -982,6 +985,8 @@ export default Controller.extend({
skipAutoSave: true,
});
this.set("skipJumpOnSave", !!opts.skipJumpOnSave);
// Scope the categories drop down to the category we opened the composer with.
if (opts.categoryId && !opts.disableScopedCategory) {
const category = this.site.categories.findBy("id", opts.categoryId);