Skip to content

Commit ca51d32

Browse files
authored
Rollup merge of rust-lang#99086 - GuillaumeGomez:search-result-crate-filter-dropdown, r=notriddle
Fix display of search result crate filter dropdown In case a crate name is too long, the `<select>` completely overflows its parent. Another problem is that there is left margin on the `select` which break the alignment. You can see both issues here: ![Screenshot from 2022-07-09 15-31-12](https://user-images.githubusercontent.com/3050060/178108959-0eb5af19-ec60-4d34-a2fd-c27147683c78.png) And with the fix: ![Screenshot from 2022-07-09 15-33-37](https://user-images.githubusercontent.com/3050060/178108980-71030a92-84ee-4ee5-98e3-f97d03a6fbaf.png) cc `@jsha` r? `@notriddle`
2 parents 0dd5c75 + 9d5e6e2 commit ca51d32

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/librustdoc/html/static/css/rustdoc.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,6 @@ table,
924924
#crate-search {
925925
min-width: 115px;
926926
margin-top: 5px;
927-
margin-left: 0.25em;
928927
padding-left: 0.3125em;
929928
padding-right: 23px;
930929
border: 1px solid;
@@ -941,6 +940,8 @@ table,
941940
background-size: 20px;
942941
background-position: calc(100% - 1px) 56%;
943942
background-image: /* AUTOREPLACE: */url("down-arrow.svg");
943+
max-width: 100%;
944+
text-overflow: ellipsis;
944945
}
945946
.search-container {
946947
margin-top: 4px;

src/test/rustdoc-gui/search-result-display.goml

+28
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,31 @@ size: (600, 100)
1010
// As counter-intuitive as it may seem, in this width, the width is "100%", which is why
1111
// when computed it's larger.
1212
assert-css: (".search-results div.desc", {"width": "570px"})
13+
14+
// Check that the crate filter `<select>` is correctly handled when it goes to next line.
15+
// To do so we need to update the length of one of its `<option>`.
16+
size: (900, 900)
17+
18+
// First we check the current width and position.
19+
assert-css: ("#crate-search", {"width": "222px"})
20+
compare-elements-position-near: (
21+
"#crate-search",
22+
"#search-settings .search-results-title",
23+
{"y": 5},
24+
)
25+
26+
// Then we update the text of one of the `<option>`.
27+
text: (
28+
"#crate-search option",
29+
"sdjfaksdjfaksjdbfkadsbfkjsadbfkdsbkfbsadkjfbkdsabfkadsfkjdsafa",
30+
)
31+
32+
// Then we compare again.
33+
assert-css: ("#crate-search", {"width": "640px"})
34+
compare-elements-position-near-false: (
35+
"#crate-search",
36+
"#search-settings .search-results-title",
37+
{"y": 5},
38+
)
39+
// And we check that the `<select>` isn't bigger than its container.
40+
assert-css: ("#search", {"width": "640px"})

0 commit comments

Comments
 (0)