Skip to content

Commit 30f4486

Browse files
Rollup merge of #85551 - GuillaumeGomez:fix-search-result-overflow, r=jsha
Fix search results display Fixes #85544. cc `@dns2utf8` r? `@jsha`
2 parents 2a8eeaf + 8968c0e commit 30f4486

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

src/librustdoc/html/static/rustdoc.css

+32-5
Original file line numberDiff line numberDiff line change
@@ -759,25 +759,40 @@ a {
759759

760760
.search-results.active {
761761
display: block;
762+
/* prevent overhanging tabs from moving the first result */
763+
clear: both;
762764
}
763765

764-
.search-results .desc {
766+
.search-results .desc > span {
765767
white-space: nowrap;
766768
text-overflow: ellipsis;
767769
overflow: hidden;
768770
display: block;
769771
}
770772

771-
.search-results a {
773+
.search-results > a {
774+
display: block;
775+
width: 100%;
772776
/* A little margin ensures the browser's outlining of focused links has room to display. */
773777
margin-left: 2px;
774778
margin-right: 2px;
775-
display: block;
779+
border-bottom: 1px solid #aaa3;
780+
}
781+
782+
.search-results > a > div {
783+
display: flex;
784+
flex-flow: row wrap;
776785
}
777786

778-
.result-name {
787+
.search-results .result-name, .search-results div.desc, .search-results .result-description {
779788
width: 50%;
780-
float: left;
789+
}
790+
.search-results .result-name {
791+
padding-right: 1em;
792+
}
793+
794+
.search-results .result-name > span {
795+
display: inline-block;
781796
}
782797

783798
.result-name span.primitive::after {
@@ -1733,6 +1748,18 @@ details.undocumented[open] > summary::before {
17331748
.search-container > div {
17341749
width: calc(100% - 32px);
17351750
}
1751+
1752+
/* Display an alternating layout on tablets and phones */
1753+
.search-results > a {
1754+
border-bottom: 1px solid #aaa9;
1755+
padding: 5px 0px;
1756+
}
1757+
.search-results .result-name, .search-results div.desc, .search-results .result-description {
1758+
width: 100%;
1759+
}
1760+
.search-results div.desc, .search-results .result-description {
1761+
padding-left: 2em;
1762+
}
17361763
}
17371764

17381765
@media print {

src/librustdoc/html/static/search.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -994,8 +994,8 @@ window.initSearch = function(rawSearchIndex) {
994994
("<span class=\"alias\"><b>" + item.alias + " </b></span><span " +
995995
"class=\"grey\"><i>&nbsp;- see&nbsp;</i></span>") : "") +
996996
item.displayPath + "<span class=\"" + type + "\">" +
997-
name + "</span></div><div>" +
998-
"<span class=\"desc\">" + item.desc +
997+
name + "</span></div><div class=\"desc\">" +
998+
"<span>" + item.desc +
999999
"&nbsp;</span></div></div></a>";
10001000
});
10011001
output += "</div>";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
goto: file://|DOC_PATH|/test_docs/index.html
2+
size: (900, 1000)
3+
write: (".search-input", "test")
4+
// Waiting for the search results to appear...
5+
wait-for: "#titles"
6+
// The width is returned by "getComputedStyle" which returns the exact number instead of the
7+
// CSS rule which is "50%"...
8+
assert: (".search-results div.desc", {"width": "320px"})
9+
size: (600, 100)
10+
// As counter-intuitive as it may seem, in this width, the width is "100%", which is why
11+
// when computed it's larger.
12+
assert: (".search-results div.desc", {"width": "570px"})

0 commit comments

Comments
 (0)