FIX: gives composer options to post:highlight trigger (#15384)

This change allows to prevent page jump, when jump is prevented, due to highlightPost causing a `focus()`.
This commit is contained in:
Joffrey JAFFEUX 2021-12-21 19:53:07 +01:00 committed by GitHub
parent 80591724cf
commit 96982ca2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import { isBlank } from "@ember/utils";
import { later, schedule, scheduleOnce, throttle } from "@ember/runloop";
import AddArchetypeClass from "discourse/mixins/add-archetype-class";
import ClickTrack from "discourse/lib/click-track";
@ -48,8 +49,10 @@ export default Component.extend(
}
},
_highlightPost(postNumber) {
scheduleOnce("afterRender", null, highlightPost, postNumber);
_highlightPost(postNumber, options = {}) {
if (isBlank(options.jump) || options.jump !== false) {
scheduleOnce("afterRender", null, highlightPost, postNumber);
}
},
_hideTopicInHeader() {

View File

@ -894,7 +894,11 @@ export default Controller.extend({
if (result.responseJson.action === "create_post") {
this.appEvents.trigger("composer:created-post");
this.appEvents.trigger("post:highlight", result.payload.post_number);
this.appEvents.trigger(
"post:highlight",
result.payload.post_number,
options
);
}
if (this.get("model.draftKey") === Composer.NEW_TOPIC_KEY) {