Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sidebars and branding block sticky/fixed on larger screens #4

Open
7 tasks
Ambient-Impact opened this issue Jul 2, 2022 · 0 comments
Open
7 tasks
Labels
enhancement New feature or request

Comments

@Ambient-Impact
Copy link
Member

Ambient-Impact commented Jul 2, 2022

The sidebars are basically useless on most wiki pages once you start to scroll down. These should remain in the viewport as you scroll down for much better UX.

A simplistic or naive implementation would simply have the sidebars as fixed or sticky positioning with their own scrollbars, but that would be an inelegant solution. Much better UX would be to avoid scrollbars on the sidebars but have them scroll as the viewport scrolls, pinning to either the top or bottom of the viewport as that respective edge of the sidebar makes contact. This allows the document scroll to act as the scroller for the sidebars in an indirect fashion that ends up still feeling intuitive.

Examples of this are a bit lacking, however the Sticky Sidebar library does just this, though it's a bit janky at times due to not using position: sticky; More examples:

  1. The Medium.com sidebar on larger screens.
  2. The sidebar on a lot of Read the Docs pages, such as this page for restic.

Requirements

  1. Sidebars (including the branding) must be in the viewport at all time, scrolling with it but pinning to the top or bottom edge.

  2. Non-pointer focus must correctly scroll the viewport to bring the focus target into view.

  3. Should mostly work without JavaScript, probably via position: fixed and overflow-y: auto; position: sticky could work but has the problem that the viewport would need to be scrolled all the way to the bottom to access the bottom of a tall sidebar.

  4. Minimal or no jank; preferably using some hybrid of position: sticky and non-sticky if possible to allow the browser to handle the transition to/from on time, which is especially a noticeable problem on mobile or slower systems when using the Sticky Sidebar library.

Problems

This poses some challenges however, since the layout and document structure is more complex than the visuals indicate, and there are edge cases where the sidebar content might become inaccessible.

  1. The site branding block is not actually in the first sidebar in the HTML structure but placed via CSS to appear that way on larger screens. This allows us to avoid changing the document structure when going from small screen mode to large screen mode and vice versa, but creates multiple problems here:

    • Neither the branding block nor the first sidebar technically have any easy way to account for each others' current height. This is all handled via CSS Grid and some trickery.

    • Since the first sidebar contents and branding are not in the same container, they can't be scrolled together visually.

Solutions

Depends on #5 being implemented. Once that's done, we can focus on the next stages.

Remaining tasks

Must haves

Nice to haves

  • Use native position: sticky when a sidebar column fits within the viewport, only switching to the Sticky Sidebar implementation when the viewport becomes too short.
  • Fix the occasional frame or two of jank when scrolling quickly and hitting the top or bottom of the sidebar. This might be really difficult to do without the native position: sticky handling it for us.
  • Remove the layoutSizeChange dependency from the JavaScript component if not used in final iteration.
@Ambient-Impact Ambient-Impact added the enhancement New feature or request label Aug 2, 2022
Ambient-Impact added a commit that referenced this issue Aug 4, 2022
Probably won't use most of this, but don't want to lose it in case we
need parts of it. See new direction:

#4
@Ambient-Impact Ambient-Impact self-assigned this Sep 11, 2022
@Ambient-Impact Ambient-Impact removed their assignment Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

1 participant