Problem
On mobile, closing an ol-popover tray (e.g. the Buy dropdown on a book page) by tapping outside it makes the page jump to the top instantly, then animate back down to where the reader was.
The tray locks page scroll by pinning <body> with position: fixed. On close, unlockBodyScroll() unpins it, which shows the page at scroll position 0, and then calls window.scrollTo() to restore the old offset. static/css/base/common.css sets html { scroll-behavior: smooth } site-wide, so that restore animates. ol-dialog and ol-drawer use the same helper.
Reproducing the bug
- On a phone (or a narrow viewport), open a book page and scroll down.
- Open the Buy dropdown so it appears as a tray.
- Tap outside the tray.
- Expected: the page stays where it was.
- Actual: the page flashes at the top, then scrolls back down.
Context
The global smooth scroll was added in #12910 so the unavailable-book banner's "available alternatives" link would glide to the related-books carousel. It also affects every other same-page link and any script scroll that doesn't set behavior, and the design system page already had to opt out of it.
Breakdown
- Restore the scroll offset with
behavior: 'instant' in scroll-lock.js.
- Remove the global
scroll-behavior: smooth and opt in only the banner link.
Problem
On mobile, closing an
ol-popovertray (e.g. the Buy dropdown on a book page) by tapping outside it makes the page jump to the top instantly, then animate back down to where the reader was.The tray locks page scroll by pinning
<body>withposition: fixed. On close,unlockBodyScroll()unpins it, which shows the page at scroll position 0, and then callswindow.scrollTo()to restore the old offset.static/css/base/common.csssetshtml { scroll-behavior: smooth }site-wide, so that restore animates.ol-dialogandol-draweruse the same helper.Reproducing the bug
Context
The global smooth scroll was added in #12910 so the unavailable-book banner's "available alternatives" link would glide to the related-books carousel. It also affects every other same-page link and any script scroll that doesn't set
behavior, and the design system page already had to opt out of it.Breakdown
behavior: 'instant'inscroll-lock.js.scroll-behavior: smoothand opt in only the banner link.