Skip to content

Commit

Permalink
fix(nav): will not scroll to top when open nav flyout
Browse files Browse the repository at this point in the history
  • Loading branch information
hirsch88 committed Aug 13, 2024
1 parent 8b6e6cc commit b6be843
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-dancers-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@baloise/ds-core': patch
---

**nav**: will not scroll to top when open nav flyout
10 changes: 7 additions & 3 deletions packages/core/src/utils/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class BalScrollHandler {
}

private target: HTMLElement | Document | undefined
private x = 0
private y = 0
private x: number | undefined = undefined
private y: number | undefined = undefined
private disabled = false

connect(el?: HTMLElement) {
Expand Down Expand Up @@ -62,7 +62,11 @@ export class BalScrollHandler {
document.body.style.position = ''
document.body.style.top = ''
document.body.style.width = ''
window.scrollTo(this.x, this.y)
if(this.x !== undefined && this.y !== undefined) {
window.scrollTo(this.x, this.y)
this.x = undefined
this.y = undefined
}
this.disabled = false
}
}
Expand Down

0 comments on commit b6be843

Please sign in to comment.