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

Fix anchor invalid redirection to search #41950

Merged
merged 1 commit into from May 14, 2017

Conversation

GuillaumeGomez
Copy link
Member

Fixes #41933.

r? @rust-lang/docs

var search = document.getElementById('search');
if (hasClass(main, 'content')) {
addClass(main, 'hidden');
}
Copy link
Member

Choose a reason for hiding this comment

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

This should be something like the following to avoid shadowing the search function and to add the class to the correct element:

var search_c = document.getElementById('search');
if (hasClass(search_c, 'content')) {
    addClass(search_c, 'hidden');
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Excellent point!

Copy link
Member Author

Choose a reason for hiding this comment

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

This was the issue actually. I thought the variable was limited to the scope, big mistake!

// perform the search. This will empty the bar if there's
// nothing there, which lets you really go back to a
// previous state with nothing in the bar.
document.getElementsByClassName('search-input')[0].value = params.search;
Copy link
Member

Choose a reason for hiding this comment

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

If params.search is undefined this should set the value to "" not "undefined" like it currently does.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

var search = document.getElementById('search');
if (hasClass(main, 'content')) {
addClass(main, 'hidden');
if (location.href.indexOf(".html?search=") !== -1) {
Copy link
Member

Choose a reason for hiding this comment

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

This would break clearing the search results so should be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems it's still working. So not sure if I tested what you had in mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh my bad, I need to test on a non local path.

@shepmaster shepmaster added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 12, 2017
@GuillaumeGomez
Copy link
Member Author

Updated.

@GuillaumeGomez GuillaumeGomez added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 13, 2017
@frewsxcv
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 13, 2017

📌 Commit b09a19b has been approved by frewsxcv

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 13, 2017
…wsxcv

Fix anchor invalid redirection to search

Fixes rust-lang#41933.

r? @rust-lang/docs
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 14, 2017
…wsxcv

Fix anchor invalid redirection to search

Fixes rust-lang#41933.

r? @rust-lang/docs
bors added a commit that referenced this pull request May 14, 2017
Rollup of 7 pull requests

- Successful merges: #41612, #41826, #41939, #41946, #41950, #41975, #41979
- Failed merges:
@bors bors merged commit b09a19b into rust-lang:master May 14, 2017
@GuillaumeGomez GuillaumeGomez deleted the rustdoc-links branch May 14, 2017 10:12
@apiraino apiraino removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking on rustdoc sidebar item results in 'undefined' page
6 participants