Bug 272624 - Using <main tabindex=-1> does not maintain scroll position when returning to the page
Summary: Using <main tabindex=-1> does not maintain scroll position when returning to ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Safari 17
Hardware: iPhone / iPad Unspecified
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2024-04-13 01:50 PDT by Dan
Modified: 2024-04-15 06:53 PDT (History)
3 users (show)

See Also:

A test-case using <main tabindex=-1> (6.86 KB, text/html)
2024-04-13 01:50 PDT, Dan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dan 2024-04-13 01:50:16 PDT
Created attachment 470911 [details]
A test-case using <main tabindex=-1>

A web page using `<main tabindex=-1>` for its main content area (a common markup pattern for „Skip to content” links) loses its scroll position on iOS Safari when navigating away from the page, then tapping the Back button. The scroll position is moved to the top of the `<main>` element.

This seems related to the fact that focus (as evidenced by document.activeElement) returns to the `<main>` element, which may cause the browser to scroll it into view.

This only happens on iOS Safari, macOS Safari works well.
Comment 1 Radar WebKit Bug Importer 2024-04-13 01:50:25 PDT
Comment 2 Ahmad Saleem 2024-04-15 06:46:31 PDT
Dan - does this use to work in previous iOS releases?
Comment 3 Dan 2024-04-15 06:53:13 PDT
Ahmad, based on my tests in Browserstack, the issue seems to have been introduced around iOS/Safari 14.