Skip to content

Conversation

@GuillaumeGomez
Copy link
Member

Someone on mastodon rightfully pointed out that having a visual indication that some search results were hidden would be a good idea if the "hide deprecated items" setting is enabled. In particular if no results are displayed.

It looks like this:

Screenshot From 2026-01-24 00-26-33

r? @lolbinarycat

@rustbot
Copy link
Collaborator

rustbot commented Jan 23, 2026

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 Jan 23, 2026
if (active) {
const previous = active.previousElementSibling;
if (previous) {
if (previous && previous.className !== DEPRECATED_COUNT_SELECTOR) {
Copy link
Member Author

Choose a reason for hiding this comment

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

When using the "up" arrow to go back from the search results to the search input, we need to skip the "marker".

Interestingly enough, we did it nicely the other way (going from search input to search results with down arrow), the selector targets directly the first item.

.deprecated-count {
display: none;
}
.hide-deprecated-items .deprecated-count:not(:empty) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The :not(:empty) is a little trick I thought about to not have to add conditions in JS to hide/show the marker. It's entirely based on whether it has content and if the setting is enabled. Quite proud of that one for some reason. 😆

Copy link
Contributor

Choose a reason for hiding this comment

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

This trick should probably have a comment explaining it.

Copy link
Member Author

Choose a reason for hiding this comment

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

So I can share my pride with the rest of the world. I approve this idea! =D

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the marker-hidden-deprecated-search branch from e436693 to 0e240d3 Compare January 24, 2026 11:19
@lolbinarycat
Copy link
Contributor

Looks pretty good, just would like to see a comment explaining how those two rules controlling the display will interact (despite being core to the concept of css, css's specificity rules are rarely taken advantage of, and not super widely understood).

@GuillaumeGomez
Copy link
Member Author

I added a comment. Do you see another CSS rule which might need explanations?

@lolbinarycat
Copy link
Contributor

Hold on, can't you put the display:none; property inside a .hide-deprecated-items .deprecated-count:empty block? "hide if empty" seems more intuitive than "hide, unless not empty".

Actually I'm talking myself out of it, the current way has better graceful degradation on old browsers that don't support :not.

Maybe just put a comment to the effect of "this will be overridden if there are any deprecated items in the search results" next to the display: none property.

I haven't noticed anything else that could use a comment in this file, but I haven't looked very carefully either.

@GuillaumeGomez
Copy link
Member Author

Hum, that seems like a bit too precise comment there no? It's writing in plain text what this is doing.

@lolbinarycat
Copy link
Contributor

My logic is that css specificity is not widely understood, and if you're not aware of its existence, it wouldn't be obvious that one rule would override the other. This is just my intuition and I have no data to back it up (I don't know if such data exists), but also this is the Rust project, and most contributors will be Rust programmers, not web developers (and many web developers will use tailwind or similar instead of idiomatic css)...

Even just having "css specificity" somewhere in the existing comment would leave a breadcrumb for someone to follow if they were confused.

Ultimately, it's a pretty small thing, and I'm not going to block the PR on it if you don't think it's worth it.

@GuillaumeGomez
Copy link
Member Author

Hum. What I suggest then is to send a follow-up as I'm really having issues to see what you have in mind. Maybe I'm simply not understanding what you mean. Looking forward to the follow-up then and thanks for the review!

@bors r=lolbinarycat rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 28, 2026

📌 Commit c60ae4d has been approved by lolbinarycat

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Jan 28, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 29, 2026
…cated-search, r=lolbinarycat

[rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results

Someone on mastodon rightfully pointed out that having a visual indication that some search results were hidden would be a good idea if the "hide deprecated items" setting is enabled. In particular if no results are displayed.

It looks like this:

<img width="861" height="228" alt="Screenshot From 2026-01-24 00-26-33" src="https://github.com/user-attachments/assets/93aeef11-a550-47dc-9c78-219ea4fd822c" />

r? @lolbinarycat
rust-bors bot pushed a commit that referenced this pull request Jan 29, 2026
Rollup of 8 pull requests

Successful merges:

 - #150474 (Tidy: detect ui tests subdirectory changes so `tests/ui/README.md` stays in sync)
 - #150572 (Improve move error diagnostic for `AsyncFn` closures)
 - #151596 (Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro)
 - #151802 (Make `QueryDispatcher::Qcx` an associated type)
 - #151559 ([rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results)
 - #151665 (Fix contrast ratio for `Since` element in rustodoc dark theme)
 - #151798 (Update `askama` to `0.15.3`)
 - #151800 (Subscribe myself to translation diagnostics)
rust-bors bot pushed a commit that referenced this pull request Jan 29, 2026
Rollup of 12 pull requests

Successful merges:

 - #150474 (Tidy: detect ui tests subdirectory changes so `tests/ui/README.md` stays in sync)
 - #150572 (Improve move error diagnostic for `AsyncFn` closures)
 - #151596 (Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro)
 - #151802 (Make `QueryDispatcher::Qcx` an associated type)
 - #149110 (Implement `cast_slice` for raw pointer types)
 - #151559 ([rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results)
 - #151665 (Fix contrast ratio for `Since` element in rustdoc dark theme)
 - #151785 (Stabilize feature(push_mut))
 - #151798 (Update `askama` to `0.15.3`)
 - #151800 (Subscribe myself to translation diagnostics)
 - #151804 (Document, sort, and tweak spellcheck entries in `typos.toml`)
 - #151805 (Fix grammar in `env::current_exe()#Security`)
@rust-bors rust-bors bot merged commit f5822b6 into rust-lang:main Jan 29, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 29, 2026
rust-timer added a commit that referenced this pull request Jan 29, 2026
Rollup merge of #151559 - GuillaumeGomez:marker-hidden-deprecated-search, r=lolbinarycat

[rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results

Someone on mastodon rightfully pointed out that having a visual indication that some search results were hidden would be a good idea if the "hide deprecated items" setting is enabled. In particular if no results are displayed.

It looks like this:

<img width="861" height="228" alt="Screenshot From 2026-01-24 00-26-33" src="https://github.com/user-attachments/assets/93aeef11-a550-47dc-9c78-219ea4fd822c" />

r? @lolbinarycat
@GuillaumeGomez GuillaumeGomez deleted the marker-hidden-deprecated-search branch January 29, 2026 13:28
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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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