From df1e4af7fc244e929c900a842048cf39f8dead61 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Mon, 16 Nov 2020 11:29:48 +0100 Subject: [PATCH] fix(profile): correctly change page title when closing profile modal, fixes #12760, thanks @aevix --- website/client/src/components/userMenu/profile.vue | 12 ++++++++++++ .../client/src/components/userMenu/profileModal.vue | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/website/client/src/components/userMenu/profile.vue b/website/client/src/components/userMenu/profile.vue index 667b2effd8..d6b4038508 100644 --- a/website/client/src/components/userMenu/profile.vue +++ b/website/client/src/components/userMenu/profile.vue @@ -776,6 +776,7 @@ export default { content: Content, user: null, userLoaded: false, + oldTitle: null, }; }, computed: { @@ -831,7 +832,18 @@ export default { }, mounted () { this.loadUser(); + this.oldTitle = this.$store.state.title; this.selectPage(this.startingPage); + this.$root.$on('habitica:restoreTitle', () => { + if (this.oldTitle) { + this.$store.dispatch('common:setTitle', { + fullTitle: this.oldTitle, + }); + } + }); + }, + beforeDestroy () { + this.$root.$off('habitica:restoreTitle'); }, methods: { async loadUser () { diff --git a/website/client/src/components/userMenu/profileModal.vue b/website/client/src/components/userMenu/profileModal.vue index f148af9b70..06b2611cc1 100644 --- a/website/client/src/components/userMenu/profileModal.vue +++ b/website/client/src/components/userMenu/profileModal.vue @@ -4,6 +4,7 @@ size="lg" :hide-footer="true" :hide-header="true" + @hide="beforeHide" @hidden="onHidden" @shown="onShown()" > @@ -52,6 +53,11 @@ export default { onShown () { window.history.pushState('', null, this.path); }, + beforeHide () { + if (this.$route.path !== window.location.pathname) { + this.$root.$emit('habitica:restoreTitle'); + } + }, onHidden () { if (this.$route.path !== window.location.pathname) { this.$router.go(-1);