Skip to content

Fix bug when rustdoc "go to only result" setting is not working as expected"#158308

Open
GuillaumeGomez wants to merge 1 commit into
rust-lang:mainfrom
GuillaumeGomez:fix-only-result-bug
Open

Fix bug when rustdoc "go to only result" setting is not working as expected"#158308
GuillaumeGomez wants to merge 1 commit into
rust-lang:mainfrom
GuillaumeGomez:fix-only-result-bug

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

Can be reproduced as follows on std docs:

  • Disable the Directly go to item in search if there is only one result setting
  • Search for "var" (without the quotes)
  • Enable the Directly go to item in search if there is only one result setting
  • Reload the page
  • It now goes to another page although there are more than one result.

Thanks @poliorcetics for the detailed steps. :)

The problem is that, we don't necessarily create the tabs in one particular order and if any tab has exactly one result, in some cases, it's good enough for the feature. So this PR adds a check to ensure it's only taken into consideration in the first tab, ignoring the other two.

cc @lolbinarycat
r? @notriddle

@rustbot

rustbot commented Jun 23, 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 A-rustdoc-search Area: Rustdoc's search feature 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 Jun 23, 2026
go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
// We enter it into the search.
click: "#search-button"
wait-for: "#alternative-display .search-input"

@GuillaumeGomez GuillaumeGomez Jun 23, 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.

I'm surprised it worked before to directly write into the search input even if it's not displayed. It triggered a bug when I wrote Whitespace into it: it only had pace, the beginning was removed. I think it's because the item gets moved in-between and if there are few enough letters, it works, but it's only by change.

View changes since the review

write-into: (".search-input", "HasALongTraitWithParams")
wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"}
assert-window-property: ({"location": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)
assert-window-property: ({"location"."pathname": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)

@GuillaumeGomez GuillaumeGomez Jun 23, 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.

I have no clue how this could have work before since window.location is indeed an object. Gonna investigate on browser-ui-test side.

View changes since the review

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.

go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
show-text: true

// The setting should be disabled.

@GuillaumeGomez GuillaumeGomez Jun 23, 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.

To confirm this test works, run it without the fix. It should fail. :)

View changes since the review

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 A-rustdoc-search Area: Rustdoc's search feature 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.

3 participants