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

rustdoc mobile: fix scroll offset when jumping to internal id #93067

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

jsha
Copy link
Contributor

@jsha jsha commented Jan 19, 2022

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
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez,@Folyd

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 19, 2022
@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jan 19, 2022

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
Copy link
Contributor Author

jsha commented Jan 19, 2022

Added a test!

@GuillaumeGomez
Copy link
Member

r=me once CI pass then. :)

@jsha
Copy link
Contributor Author

jsha commented Jan 19, 2022

@bors r=GuillaumeGomez rollup

@bors
Copy link
Contributor

bors commented Jan 19, 2022

📌 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
…askrgr

Rollup of 17 pull requests

Successful merges:

 - rust-lang#91032 (Introduce drop range tracking to generator interior analysis)
 - rust-lang#92856 (Exclude "test" from doc_auto_cfg)
 - rust-lang#92860 (Fix errors on blanket impls by ignoring the children of generated impls)
 - rust-lang#93038 (Fix star handling in block doc comments)
 - rust-lang#93061 (Only suggest adding `!` to expressions that can be macro invocation)
 - rust-lang#93067 (rustdoc mobile: fix scroll offset when jumping to internal id)
 - rust-lang#93086 (Add tests to ensure that `let_chains` works with `if_let_guard`)
 - rust-lang#93087 (Fix src/test/run-make/raw-dylib-alt-calling-convention)
 - rust-lang#93091 (⬆ chalk to 0.76.0)
 - rust-lang#93094 (src/test/rustdoc-json: Check for `struct_field`s in `variant_tuple_struct.rs`)
 - rust-lang#93098 (Show a more informative panic message when `DefPathHash` does not exist)
 - rust-lang#93099 (rustdoc: auto create output directory when "--output-format json")
 - rust-lang#93102 (Pretty printer algorithm revamp step 3)
 - rust-lang#93104 (Support --bless for pp-exact pretty printer tests)
 - rust-lang#93114 (update comment for `ensure_monomorphic_enough`)
 - rust-lang#93128 (Add script to prevent point releases with same number as existing ones)
 - rust-lang#93136 (Backport the 1.58.1 release notes to master)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 35a53b2 into rust-lang:master Jan 21, 2022
@rustbot rustbot added this to the 1.60.0 milestone Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants