Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix(bal-nav): Opening menu scrolls page back to top #1433

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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