Skip to content

Commit

Permalink
Merge branch 'main' into THR-18-dev-feature-h5p-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
CeEv authored Nov 6, 2023
2 parents c81c696 + b01b942 commit fcdf3fe
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/pages/rooms/RoomDetails.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export default defineComponent({
},
},
async created() {
if (this.$route.query && this.$route.query.tab) {
if (this.$route.query?.tab) {
this.setActiveTab(this.$route.query.tab);
}
Expand All @@ -419,7 +419,22 @@ export default defineComponent({
document.title = buildPageTitle(this.roomData.title);
},
mounted() {
window.addEventListener("pageshow", this.setActiveTabIfPageCached);
},
beforeDestroy() {
window.removeEventListener("pageshow", this.setActiveTabIfPageCached);
},
methods: {
setActiveTabIfPageCached(event) {
if (event.persisted) {
if (this.$route.query?.tab) {
this.setActiveTab(this.$route.query.tab);
} else {
this.setActiveTab("learn-content");
}
}
},
setActiveTab(tabName) {
const index = this.tabItems.findIndex(
(tabItem) => tabItem.name === tabName
Expand Down Expand Up @@ -494,7 +509,7 @@ export default defineComponent({
watch: {
tabIndex(newIndex) {
if (newIndex >= 0 && newIndex < this.tabItems.length) {
this.$router.replace({
this.$router.push({
query: { ...this.$route.query, tab: this.tabItems[newIndex].name },
});
}
Expand Down

0 comments on commit fcdf3fe

Please sign in to comment.