Skip to content

[rustdoc] Only generate search DOM elements if the search is actually needed - #160639

Open
GuillaumeGomez wants to merge 3 commits into
rust-lang:mainfrom
GuillaumeGomez:search-dom
Open

[rustdoc] Only generate search DOM elements if the search is actually needed#160639
GuillaumeGomez wants to merge 3 commits into
rust-lang:mainfrom
GuillaumeGomez:search-dom

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

I realized that we were generating the search DOM elements (everything contained into #search) all the times, even when there is no search query parameters in the URL. That seems unnecessary so I reworked the JS a bit to remove that.

r? @lolbinarycat

@rustbot

rustbot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @lolbinarycat

@rustbot rustbot added A-rustdoc-js Area: Rustdoc's JS front-end S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Aug 6, 2026
@@ -16,6 +17,7 @@ define-function: ("collapsed-from-search", [], block {
// Then we collapse the section again...
set-property: ("#implementations-list .implementors-toggle", {"open": "false"})
// Then we run the search.
call-function: ("open-search", {})

@GuillaumeGomez GuillaumeGomez Aug 6, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah that was my original "quest": looking at fixing the new flakyness which happened in #159593 (comment). ^^'

View changes since the review

@@ -53,7 +53,7 @@ define-function: (
"#src-sidebar details[open] > .files a:not(.selected):focus",
{"color": |color_hover|, "background-color": |background_hover|},
)
focus: ".search-input"
focus: "#search-button"

@GuillaumeGomez GuillaumeGomez Aug 6, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In this file, we use focus to "focus away" from the current element. Since search-input isn't available anymore, I just pick another item on the page.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

adding a comment like "// focus something else to unfocus" seems like it would improve the readability of that test, then.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, gonna add comments.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Added the missing Typescript type definition update and CI is now happy.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Added comments as suggested for clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-js Area: Rustdoc's JS front-end S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants