Skip to content

Commit

Permalink
Merge pull request #5691 from getkirby/v4/fix/dropdown-position
Browse files Browse the repository at this point in the history
Remember the scroll position when opening dropdowns
  • Loading branch information
distantnative authored Sep 25, 2023
2 parents 42bdd7c + 94d7d26 commit e34c556
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions panel/src/components/Dropdowns/DropdownContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ export default {
async onOpen() {
this.isOpen = true;
// remember the current scroll position
const scrollTop = window.scrollY;
// store a global reference to the dropdown
OpenDropdown = this;
Expand All @@ -173,6 +176,8 @@ export default {
if (this.$el && this.opener) {
window.addEventListener("resize", this.position);
await this.setPosition();
// restore the scroll position
window.scrollTo(0, scrollTop);
this.$emit("open");
}
},
Expand Down

0 comments on commit e34c556

Please sign in to comment.