Add a marker to tell users that there are hidden (deprecated) items in the search results
This commit is contained in:
parent
88ad3d44ca
commit
fcbb046ced
2 changed files with 21 additions and 2 deletions
|
|
@ -341,7 +341,8 @@ summary.hideme,
|
|||
.rustdoc-breadcrumbs,
|
||||
.search-switcher,
|
||||
/* This selector is for the items listed in the "all items" page. */
|
||||
ul.all-items {
|
||||
ul.all-items,
|
||||
.deprecated-count {
|
||||
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
|
||||
}
|
||||
|
||||
|
|
@ -2652,6 +2653,14 @@ However, it's not needed with smaller screen width because the doc/code block is
|
|||
display: none;
|
||||
}
|
||||
|
||||
.deprecated-count {
|
||||
display: none;
|
||||
}
|
||||
.hide-deprecated-items .deprecated-count:not(:empty) {
|
||||
display: block;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
/*
|
||||
WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY
|
||||
If you update this line, then you also need to update the line with the same warning
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ const REGEX_INVALID_TYPE_FILTER = /[^a-z]/ui;
|
|||
|
||||
const MAX_RESULTS = 200;
|
||||
const NO_TYPE_FILTER = -1;
|
||||
const DEPRECATED_COUNT_SELECTOR = "deprecated-count";
|
||||
|
||||
/**
|
||||
* The [edit distance] is a metric for measuring the difference between two strings.
|
||||
|
|
@ -4904,7 +4905,12 @@ async function addTab(results, query, display, finishedCallback, isTypeSearch) {
|
|||
let output = document.createElement("ul");
|
||||
output.className = "search-results " + extraClass;
|
||||
|
||||
const deprecatedCountElem = document.createElement("span");
|
||||
deprecatedCountElem.className = DEPRECATED_COUNT_SELECTOR;
|
||||
output.appendChild(deprecatedCountElem);
|
||||
|
||||
let count = 0;
|
||||
let deprecatedCount = 0;
|
||||
|
||||
/** @type {Promise<string|null>[]} */
|
||||
const descList = [];
|
||||
|
|
@ -4922,6 +4928,10 @@ async function addTab(results, query, display, finishedCallback, isTypeSearch) {
|
|||
link.className = "result-" + type;
|
||||
if (obj.item.deprecated) {
|
||||
link.className += " deprecated";
|
||||
deprecatedCount += 1;
|
||||
const plural = deprecatedCount > 1 ? "s" : "";
|
||||
deprecatedCountElem.innerText =
|
||||
`${deprecatedCount} deprecated item${plural} hidden by setting`;
|
||||
}
|
||||
link.href = obj.href;
|
||||
|
||||
|
|
@ -5411,7 +5421,7 @@ function registerSearchEvents() {
|
|||
const active = document.activeElement;
|
||||
if (active) {
|
||||
const previous = active.previousElementSibling;
|
||||
if (previous) {
|
||||
if (previous && previous.className !== DEPRECATED_COUNT_SELECTOR) {
|
||||
// @ts-expect-error
|
||||
previous.focus();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue