db,
@db@typo.social avatar

Today’s thankless task: figuring out what about my bog-standard, non-JS, bag-of-HTML-pages of a personal website compels iOS Safari to jump to the top of the article every time I hit the back button, instead of maintaining the scroll position, when visiting any external link.

https://danburzo.ro/favorite-records-2023/

db,
@db@typo.social avatar

Alright, that was quick. The tabindex=-1 on <main id='main'> causes iOS Safari to activate the element and scroll it into view when returning to the page. I will look for (and file) a bug for that.

But… @aardrian also has <main tabindex=-1> on his blog, to no ill effect on iOS Safari…

https://adrianroselli.com/

Is the heuristic specific to <main id=main>?!

Edit: My bad, Adrian uses tabindex=-1 only on the home page, which exhibits the same problem FWIW.

db,
@db@typo.social avatar
siblingpastry,
@siblingpastry@mastodon.world avatar

@db @aardrian I’m not clear on how what you’re describing breaks the back button — what has been broken?

db,
@db@typo.social avatar

@siblingpastry @aardrian It resets the scroll position to the top of <main> when returning to the page after navigating away from it. I'll try to clarify the title / content.

siblingpastry,
@siblingpastry@mastodon.world avatar

@db @aardrian Sorry I was too vague there. I understand the behaviour you’re describing. But all three of the browsers you described do something different — why is Safari’s behaviour the one that you deem to be broken?

db,
@db@typo.social avatar

@siblingpastry @aardrian Well, in addition to focusing on <main>, iOS Safari scrolls to the top of it. It loses my place on the web page when I follow links.

db,
@db@typo.social avatar

@siblingpastry @aardrian I merely mentioned document.activeElement = main as what tipped me to finding the root cause. It's the scrolling to top that’s problematic.

siblingpastry,
@siblingpastry@mastodon.world avatar

@db @aardrian Gotcha. Then isn’t Chrome’s body behaviour problematic in the same way?

Does it behave better if you use the first element inside main, say the <h1>, as the skip link target?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ethstaker
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • ngwrru68w68
  • Durango
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • tacticalgear
  • mdbf
  • kavyap
  • khanakhh
  • provamag3
  • osvaldo12
  • GTA5RPClips
  • cubers
  • cisconetworking
  • everett
  • tester
  • modclub
  • megavids
  • Leos
  • normalnudes
  • anitta
  • JUstTest
  • lostlight
  • All magazines