FIX: Scroll to top on badge pages (#13694)

…so we don't end up at a random point on the page after a transition.
This commit is contained in:
Jarek Radosz 2021-07-12 02:48:23 +02:00 committed by GitHub
parent aebc6164fc
commit efac01d259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View File

@ -2,6 +2,8 @@ import Badge from "discourse/models/badge";
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
import PreloadStore from "discourse/lib/preload-store";
import { scrollTop } from "discourse/mixins/scroll-top";
import { action } from "@ember/object";
export default DiscourseRoute.extend({
model() {
@ -18,10 +20,10 @@ export default DiscourseRoute.extend({
return I18n.t("badges.title");
},
actions: {
didTransition() {
this.controllerFor("application").set("showFooter", true);
return true;
},
@action
didTransition() {
this.controllerFor("application").set("showFooter", true);
scrollTop();
return true;
},
});

View File

@ -2,7 +2,9 @@ import Badge from "discourse/models/badge";
import DiscourseRoute from "discourse/routes/discourse";
import PreloadStore from "discourse/lib/preload-store";
import UserBadge from "discourse/models/user-badge";
import { scrollTop } from "discourse/mixins/scroll-top";
import { hash } from "rsvp";
import { action } from "@ember/object";
export default DiscourseRoute.extend({
queryParams: {
@ -10,12 +12,6 @@ export default DiscourseRoute.extend({
refreshModel: true,
},
},
actions: {
didTransition() {
this.controllerFor("badges/show")._showFooter();
return true;
},
},
serialize(model) {
return model.getProperties("id", "slug");
@ -68,4 +64,11 @@ export default DiscourseRoute.extend({
controller.set("userBadges", this.userBadgesGrant);
controller.set("userBadgesAll", this.userBadgesAll);
},
@action
didTransition() {
this.controllerFor("badges/show")._showFooter();
scrollTop();
return true;
},
});