Make impl section headers sticky by GuillaumeGomez · Pull Request #133717 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

GuillaumeGomez

Fixes #133506.

It makes impl sections headings sticky, allowing users to know what impl items they are currently going through.

You can test it here.

Some technical details: to make it work (because summary use both ::before and ::after pseudo-elements), I needed to give some left margin and padding so that the other collapse/expand toggles of children items would not appear on the sticky heading's toggle. Hence why the GUI tests new values look so weird.

r? @notriddle

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-rustdoc

Relevant to the rustdoc team, which will review and decide on the PR/issue.

labels

Dec 1, 2024

@rustbot

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Forgot to push the second commit updating GUI tests...

@joshtriplett

@notriddle

It's messed up when the sidebar is hidden. Otherwise, seems fine.

@GuillaumeGomez

Kinda fixed the mess up with the sidebar button. Not perfect but sadly, we can't set an element position based on the page scroll without JS, and with JS, having a listener on the page scroll is terrible for performance. So instead, I simply make the button above the heading. It'll prevent to collapse the heading if the button is present, but I think it's ok.

@GuillaumeGomez

This comment has been minimized.

@rfcbot

This comment has been minimized.

@GuillaumeGomez

This comment has been minimized.

@rfcbot

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez added disposition-merge

This issue / PR is in PFCP or FCP with a disposition to merge it.

and removed T-rustdoc

Relevant to the rustdoc team, which will review and decide on the PR/issue.

labels

Dec 11, 2024

@GuillaumeGomez

@rfcbot

@notriddle

The trouble with this sort of thing is that it's really hard to get all the interaction features right. Here's a few cases that act weird:

@notriddle

@rfcbot concern scroll-margin-top

@rfcbot concern scroll after collapse

@rfcbot concern mobile hidden persistent navigation bar

@Manishearth

(In favor of this general design, but echo notriddle's concern that this is really tricky to get right, so we should spend some time experimenting and ensuring it works in all scenarios)

@bors

@kpreid

I'm interested in seeing this happen to make impls more comprehensible, but I would like to recommend that this sticky header should be optional. I know that optional UI features are a cost in themselves, but I have two specific reasons that unconditional stickiness could be problematic: