A platform for community discussion. Free, open, simple.
FIX: Scroll to the last position when navigating back to the tag topic list. (#11496)
Roman Rizzi4d1bc3a491b0
diff --git a/app/assets/javascripts/discourse/app/components/topic-list.js b/app/assets/javascripts/discourse/app/components/topic-list.jsindex 8c5919afe48..31f187628ae 100644--- a/app/assets/javascripts/discourse/app/components/topic-list.js+++ b/app/assets/javascripts/discourse/app/components/topic-list.js@@ -1,9 +1,9 @@import { alias, reads } from "@ember/object/computed";+import { debounce, schedule } from "@ember/runloop";import discourseComputed, { observes } from "discourse-common/utils/decorators";import Component from "@ember/component";import LoadMore from "discourse/mixins/load-more";import { on } from "@ember/object/evented";-import { schedule } from "@ember/runloop";export default Component.extend(LoadMore, {tagName: "table",@@ -73,7 +73,17 @@ export default Component.extend(LoadMore, {let scrollTo = this.session.get("topicListScrollPosition");if (scrollTo && scrollTo >= 0) {- schedule("afterRender", () => $(window).scrollTop(scrollTo + 1));+ schedule("afterRender", () => {+ debounce(+ this,+ function () {+ if (this.element && !this.isDestroying && !this.isDestroyed) {+ $(window).scrollTop(scrollTo + 1);+ }+ },+ 0+ );+ });}},diff --git a/app/assets/javascripts/discourse/app/templates/tags/show.hbs b/app/assets/javascripts/discourse/app/templates/tags/show.hbsindex a064771eb2b..38f50fab9b6 100644--- a/app/assets/javascripts/discourse/app/templates/tags/show.hbs+++ b/app/assets/javascripts/discourse/app/templates/tags/show.hbs@@ -59,6 +59,7 @@order=orderascending=ascendingchangeSort=(action "changeSort")+ scrollOnLoad=true}}{{/discovery-topics-list}}{{/if}}