FEATURE: CTRL-SHIFT-ENTER and SHIFT-Click do not scroll on post (#10939)

* FEATURE: CTRL-SHIFT-ENTER and SHIFT-Click do not scroll on post

This allows for an advanced feature where hitting control on click or
CTRL-SHIFT-ENTER will lead to a post being made but the browser not to
scroll to the end.
This commit is contained in:
Sam 2020-10-19 17:21:50 +11:00 committed by GitHub
parent 2ad4fc39b6
commit c8e0547bcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -89,7 +89,7 @@ export default Component.extend({
return computedLabel; return computedLabel;
}, },
click() { click(event) {
let { action } = this; let { action } = this;
if (action) { if (action) {
@ -98,9 +98,9 @@ export default Component.extend({
// There is already a warning in the console. // There is already a warning in the console.
this.sendAction("action", this.actionParam); this.sendAction("action", this.actionParam);
} else if (typeof action === "object" && action.value) { } else if (typeof action === "object" && action.value) {
action.value(this.actionParam); action.value(this.actionParam, event);
} else if (typeof this.action === "function") { } else if (typeof this.action === "function") {
action(this.actionParam); action(this.actionParam, event);
} }
} }

View File

@ -546,8 +546,8 @@ export default Controller.extend({
this.cancelComposer(differentDraftContext); this.cancelComposer(differentDraftContext);
}, },
save() { save(ignore, event) {
this.save(); this.save(false, { jump: !(event && event.shiftKey) });
}, },
displayEditReason() { displayEditReason() {
@ -625,7 +625,7 @@ export default Controller.extend({
disableSubmit: or("model.loading", "isUploading"), disableSubmit: or("model.loading", "isUploading"),
save(force) { save(force, options = {}) {
if (this.disableSubmit) { if (this.disableSubmit) {
return; return;
} }
@ -763,7 +763,8 @@ export default Controller.extend({
this.currentUser.set("any_posts", true); this.currentUser.set("any_posts", true);
const post = result.target; const post = result.target;
if (post && !staged) {
if (post && !staged && options.jump !== false) {
DiscourseURL.routeTo(post.url, { skipIfOnScreen: true }); DiscourseURL.routeTo(post.url, { skipIfOnScreen: true });
} }
}) })

View File

@ -14,7 +14,7 @@ export default {
// //
// iPad physical keyboard does not offer Command or Control detection // iPad physical keyboard does not offer Command or Control detection
// so use ALT-ENTER // so use ALT-ENTER
this.save(); this.save(undefined, e);
return false; return false;
} }
}, },