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 (#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

diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index 7d4c810..8567c40 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -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);

GitHub sha: 6192189fd248b1c239ce246faa7b8f83ea14e6c2

This commit appears in #14675 which was approved by CvX. It was merged by featheredtoast.