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

Remember state of top-level collapse toggle widget #48631

Merged
merged 2 commits into from
Mar 13, 2018

Conversation

focusaurus
Copy link
Contributor

This change allows the big top-right expand/collapse toggle to remember its setting across navigation or page reloads. Prior to this change, there was this annoyance:

  • browse to some docs
  • Click the minus button to collapse them
  • browse to other docs (or reload the page)
  • Everything is expanded again

The solution is based on storing a simple boolean flag in localStorage. I think it's a good improvement, but it does introduce the following potentially surprising behavior:

  • browse to some docs
  • click the minus button to collapse them
  • click to expand a particular item (not the main top-right big one)
  • reload the page, everything is collapsed

Paired with @DebugSteven on this.

@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS.

cc @GuillaumeGomez

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 1, 2018
@@ -1623,6 +1623,7 @@
function toggleAllDocs() {
var toggle = document.getElementById("toggle-all-docs");
if (hasClass(toggle, "will-expand")) {
updateLocalStorage("collapse", "false");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like "too simple" for a name. Can you replace it with "rustdoc-collapse" please?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please use booleans instead of strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values end up in localStorage, which converts all values to strings so I thought it clearer to avoid any type coercion and use strings always.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't know, thanks for the clarification! Then just ignore this comment.

@@ -1632,6 +1633,7 @@
collapseDocs(e, "show");
});
} else {
updateLocalStorage("collapse", "true");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@@ -1972,6 +1974,10 @@
window.onresize = function() {
hideSidebar();
};

if (getCurrentValue("collapse") === "true") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update this line as well. ;)

@pietroalbini
Copy link
Member

The author addressed @GuillaumeGomez concerns. Could someone from @rust-lang/docs review this?

@QuietMisdreavus
Copy link
Member

This is great! Thanks for following up on @GuillaumeGomez's comment. This is something i've wanted myself, so i'm glad you were able to get it rolling.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 12, 2018

📌 Commit 2dd81c8 has been approved by QuietMisdreavus

@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 Mar 12, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Mar 12, 2018
…g, r=QuietMisdreavus

Remember state of top-level collapse toggle widget

This change allows the big top-right expand/collapse toggle to remember its setting across navigation or page reloads. Prior to this change, there was this annoyance:

- browse to some docs
- Click the minus button to collapse them
- browse to other docs (or reload the page)
- Everything is expanded again

The solution is based on storing a simple boolean flag in localStorage. I think it's a good improvement, but it does introduce the following potentially surprising behavior:

- browse to some docs
- click the minus button to collapse them
- click to expand a particular item (not the main top-right big one)
- reload the page, everything is collapsed

Paired with @DebugSteven on this.
bors added a commit that referenced this pull request Mar 12, 2018
Rollup of 13 pull requests

- Successful merges: #48201, #48705, #48725, #48824, #48877, #48880, #48887, #48928, #48934, #48480, #48631, #48898, #48954
- Failed merges:
@bors bors merged commit 2dd81c8 into rust-lang:master Mar 13, 2018
@focusaurus focusaurus deleted the remember-collapse-setting branch March 13, 2018 02:55
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.

7 participants