.scrollIntoView block: 'center' causes the element to be centered within the browser viewport.

Avatar
Posts 6 10

All instances of .scrollIntoView({ behavior: 'smooth', block: 'center' }) in show.php cause the page to scroll to the middle of the target post rather than to its beginning. This happens because block: 'center' aligns the center of the post with the center of the viewport.

This is especially noticeable in topics with a very long first post (for example: https://flatboard.org/d/181-flatboard-5-7-2-beacon-release). When you read the post to the end and then use the ︽ button to return to the top of the page, the view stops around the middle of the post instead of at its beginning.

I tested changing block: 'center' to block: 'start' on my installation, and now the [Original post], [Previous post], [Next post], and [Now] buttons in "post-scrubber-card" work perfectly, always scrolling to the start of the target post.

  • cosmetic issues low priority
Avatar
Posts 470 2087

Thanks for the detailed report, and for testing a fix before posting it. That made this easy to confirm.
You got the cause exactly right. The post-scrubber buttons (Original, Previous, Next, Now) all scrolled with scrollIntoView({ block: 'center' }). On a short post you barely notice it. On a long opening post, the "back to top" button drops you in the middle instead of at the top, which is what you ran into.
I've moved every scrubber navigation call to block: 'start':

  • the four buttons
  • the unread-jump button
  • dragging the handle and clicking the track
    It's fixed in both the premium theme and the core view the other themes share, so it lands everywhere, not just on premium.
    Permalink jumps stay on block: 'center' on purpose. When you click a post's date or open a #post-123 link, centering the one post you asked for reads better than pinning it to the top edge.
    One bonus while I was in there: the j/k keyboard navigation had two handlers stepping on each other, one of them pointing at a CSS class that doesn't exist in any template. Cleaned that up too.
    Ships in the next release. Thanks again for the catch.
Log in to reply
Navigation
2 Posts
post #1
06 Jun 2026
By Utilisateur
Statistics
182
Discussions
982
Replies
25
Flatboarders
6
Contributors
New member : Nononsense
Online
37 Guests online