UX: Make toggling to filtered replies mode less jumpy. (#15240)

Previously we would jump to the first two replies but it made the
transition very jumpy depending on how long the post being selected is.
This commit is contained in:
Alan Guo Xiang Tan 2021-12-09 10:03:22 +08:00 committed by GitHub
parent e668b3dc71
commit 4d1c84f15f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -266,11 +266,13 @@ export default RestModel.extend({
filterReplies(postNumber, postId) {
this.cancelFilter();
this.set("filterRepliesToPostNumber", postNumber);
this.appEvents.trigger("post-stream:filter-replies", {
topic_id: this.get("topic.id"),
post_number: postNumber,
post_id: postId,
});
return this.refresh({ refreshInPlace: true }).then(() => {
const element = document.querySelector(`#post_${postNumber}`);
@ -280,16 +282,13 @@ export default RestModel.extend({
: null;
this.appEvents.trigger("post-stream:refresh");
DiscourseURL.jumpToPost(postNumber, {
originalTopOffset,
});
const replyPostNumbers = this.posts.mapBy("post_number");
replyPostNumbers.splice(0, 2);
schedule("afterRender", () => {
replyPostNumbers.forEach((postNum) => {
highlightPost(postNum);
});
highlightPost(postNumber);
});
});
},