diff --git a/src/components/face-category/FacetCategory.ts b/src/components/face-category/FacetCategory.ts index affe782..447340a 100644 --- a/src/components/face-category/FacetCategory.ts +++ b/src/components/face-category/FacetCategory.ts @@ -79,11 +79,11 @@ export default class FacetCategory extends Vue { } toggle(): void { - if (this.collapsed == true) { - this.collapsed = false; - } else if (this.collapsed == false) { - this.collapsed = true; - //list.children("li:gt(4)").hide(); + this.collapsed = !this.collapsed; + + // Scroll to the top of the page only when collapsing + if (this.collapsed) { + this.scrollTop(); } } @@ -94,6 +94,19 @@ export default class FacetCategory extends Vue { filterItem.category = this.filterName; filterItem.active = true; // this.$emit("filter", filterItem); + + // Scroll to the top of the page when activating a new filter + this.scrollTop(); + return filterItem; } + + scrollTop(): void { + setTimeout(() => { + window.scrollTo({ + top: 0, + behavior: 'smooth' // Smooth scroll to the top + }); + }, 50); // Delay to allow the DOM to update + } } diff --git a/src/views/search-view/search-view-component.vue b/src/views/search-view/search-view-component.vue index 9e20663..4fa064f 100644 --- a/src/views/search-view/search-view-component.vue +++ b/src/views/search-view/search-view-component.vue @@ -23,7 +23,8 @@