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

feat(rustdoc): open sidebar menu when links inside it are focused #87180

Merged
merged 1 commit into from
Jul 16, 2021

Conversation

notriddle
Copy link
Contributor

@notriddle notriddle commented Jul 16, 2021

Fixes #87172

Based on #87167 (which should be merged first)

r? @GuillaumeGomez

Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html

@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

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

GuillaumeGomez commented Jul 16, 2021

There is a much simpler way to do it. I tested locally with:

$ git diff
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 9e3ad667531..8cddd85854a 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1729,7 +1729,7 @@ details.undocumented[open] > summary::before {
                width: calc(100% + 30px);
        }
 
-       .show-it {
+       .show-it, .sidebar-elems:focus-within {
+               z-index: 2;
                left: 0;
        }

With this, no need for JS. :)

The z-index: 2; is needed because .sidebar won't have the .mobile class and so the z-index of the sidebar won't be applied. The sidebar won't be completely displayed though but I consider that not adding JS is much better.

More information on :focus-within here.

Also, can you add a test in rustdoc-gui please? There is README file in src/test/rustdoc-gui to help you.

@notriddle notriddle force-pushed the notriddle/sidebar-keyboard-mobile branch from 5af79dd to 10d00a3 Compare July 16, 2021 15:26
@notriddle
Copy link
Contributor Author

@GuillaumeGomez Okay, that's done.

Fixes rust-lang#87172

Based on rust-lang#87167 (which should be merged first)

Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html

Co-authored-by: Guillaume Gomez <guillaume.gomez@huawei.com>
@notriddle notriddle force-pushed the notriddle/sidebar-keyboard-mobile branch from 10d00a3 to 0ea2980 Compare July 16, 2021 15:32
@GuillaumeGomez
Copy link
Member

Awesome, thanks! Just waiting for CI then I r+.

@GuillaumeGomez
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Jul 16, 2021

📌 Commit 0ea2980 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 Jul 16, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 16, 2021
…d-mobile, r=GuillaumeGomez

feat(rustdoc): open sidebar menu when links inside it are focused

Fixes rust-lang#87172

Based on rust-lang#87167 (which should be merged first)

r? `@GuillaumeGomez`

Preview it at https://notriddle.com/notriddle-rustdoc-test/std/index.html
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 16, 2021
…laumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#87107 (Loop over all opaque types instead of looking at just the first one with the same DefId)
 - rust-lang#87158 (Suggest full enum variant for local modules)
 - rust-lang#87174 (Stabilize `[T; N]::map()`)
 - rust-lang#87179 (Mark `const_trait_impl` as active)
 - rust-lang#87180 (feat(rustdoc): open sidebar menu when links inside it are focused)
 - rust-lang#87188 (Add GUI test for auto-hide-trait-implementations setting)
 - rust-lang#87200 (TAIT: Infer all inference variables in opaque type substitutions via InferCx)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 12ed22f into rust-lang:master Jul 16, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 16, 2021
@notriddle notriddle deleted the notriddle/sidebar-keyboard-mobile branch May 21, 2022 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc sidebar is not accessible from keyboard on small screens
5 participants