rustdoc mobile: fix scroll offset when jumping to internal id by jsha · Pull Request #93067 · 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

Conversation10 Commits1 Checks0 Files changed

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 }})

jsha

Followup to #92692. The semantics of scroll-margin-top are a little surprising - the attribute needs to be applied to the element that gets scrolled into the viewport, not the scrolling element.

This fixes an issue where clicking on a method (or other item) from the sidebar takes you to a scroll position where the topbar covers up the method name.

I'm interested in ideas for how to test this with browser-ui-test, but I think it doesn't yet have what I need. What I need is an assert that <element>.getBoundingClientRect().y is > 45.

Demo: https://rustdoc.crud.net/jsha/fix-scroll-padding-top/std/string/struct.String.html#method.extend_from_within

r? @GuillaumeGomez

@jsha jsha added T-rustdoc

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

A-rustdoc-ui

Area: Rustdoc UI (generated HTML)

labels

Jan 19, 2022

@rust-highfive

GuillaumeGomez

@GuillaumeGomez

I'm interested in ideas for how to test this with browser-ui-test, but I think it doesn't yet have what I need. What I need is an assert that <element>.getBoundingClientRect().y is > 45.

Maybe the following would work: click on an element. Check that the element has the scrollbar-top property? Otherwise please tell me what you need in browser-ui-test and I'll add it.

Otherwise, this PR looks good to me minus the missing test. :)

Thanks a lot for this improvement!

@jsha

@jsha

GuillaumeGomez

GuillaumeGomez

@GuillaumeGomez

r=me once CI pass then. :)

@jsha

@bors r=GuillaumeGomez rollup

@bors

📌 Commit 801ac0e has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

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

labels

Jan 19, 2022

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jan 21, 2022

@bors

…askrgr

Rollup of 17 pull requests

Successful merges:

Failed merges:

r? @ghost @rustbot modify labels: rollup

Labels

A-rustdoc-ui

Area: Rustdoc UI (generated HTML)

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-rustdoc

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