quasar
quasar copied to clipboard
fix(QDialog): restore scroll after close if only hash/query changed #…
What kind of change does this PR introduce?
- [x] Bugfix
- [ ] Feature
- [ ] Documentation
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [ ] Other, please describe:
Does this PR introduce a breaking change?
- [ ] Yes
- [x] No
The PR fulfills these requirements:
- [x] It's submitted to the
devbranch - [x] When resolving a specific issue, it's referenced in the PR's title (e.g.
fix: #18185) - [ ] It's been tested on a Cordova (iOS, Android) app
- [ ] It's been tested on an Electron app
- [ ] Any necessary documentation has been added or updated in the docs or explained in the PR's description.
Description / What problem is solved:
QDialog does not restore scroll position if the URL hash or query parameters change while the dialog is open.
Currently, scroll is restored only if window.location.href === href, which fails when only hash/query changes.
This change updates the check to compare only the route path (window.location.pathname) instead of the full URL.
Scroll is now restored correctly after closing the dialog if the route path has not changed.
Code change:
// before:
if (window.location.href === href) {
window.scrollTo(scrollPositionX, scrollPositionY)
}
// after:
if (window.location.pathname === new URL(href).pathname) {
window.scrollTo(scrollPositionX, scrollPositionY)
}