Skip to content

Commit ae31d6a

Browse files
authored
fix: let gambit suggestions wrap instead of running off the dropdown (#4888)
Dropdown items are laid out as single lines and ellipsised, which is right for a menu of commands but not for the gambit rows in the search modal. Those rows document the query syntax, and the value shown against `is:` is every boolean gambit joined into one string — it grows with each extension that registers one, so there is no width at which truncating it stays useful. On a forum with a handful of extensions installed the row was already being cut off mid-word. The row now wraps. `white-space`, `overflow` and `text-overflow` are reset alongside the defaults they override so the two are read together; the generic rule matches on two classes and two elements, so a reset declared further down the file on the class alone would have lost the cascade and silently done nothing. Wrapping then needs the flex containers to allow it: a flex item will not shrink below the intrinsic width of its text without `min-width: 0`, and the key and value need `flex-wrap` to move onto separate lines. The key keeps its own line, since it is the label the row is identified by. Now that a row can be taller than one line, the alignment shifts from centre to the first line so the key, its value and the add/negate buttons all sit on the same baseline rather than floating against the middle of a wrapped block.
1 parent c4ce10c commit ae31d6a

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

framework/core/less/common/Dropdown.less

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@
5656
align-items: flex-start;
5757
}
5858

59+
// Gambit rows document the query syntax rather than naming a command, and
60+
// the value of `is:` is every boolean gambit joined together — it grows
61+
// with each extension that registers one, so there is no width at which
62+
// ellipsising it stays useful. Declared here to override the single-line
63+
// defaults above at equal specificity.
64+
&.GambitsAutocomplete-gambit {
65+
white-space: normal;
66+
overflow: visible;
67+
text-overflow: clip;
68+
}
69+
5970
&.disabled {
6071
opacity: 0.4;
6172
background: none !important;
@@ -247,22 +258,37 @@
247258
.GambitsAutocomplete {
248259
&-gambit {
249260
display: flex;
250-
align-items: center;
261+
// A wrapped value makes the row taller than one line, so the actions align
262+
// to the first line rather than to the middle of the whole row.
263+
align-items: flex-start;
251264

252265
> button {
253266
flex-grow: 1;
267+
// Without this the button refuses to shrink below the intrinsic width of
268+
// its text, so a long value pushes the row out of the dropdown instead of
269+
// wrapping inside it.
270+
min-width: 0;
254271
cursor: pointer;
255272
gap: 4px;
256273
display: flex;
257-
align-items: center;
274+
flex-wrap: wrap;
275+
align-items: baseline;
276+
text-align: start;
258277
padding: 8px 15px;
259278
margin: -8px 0 -8px -15px;
260279
}
261280
&-key {
262281
font-weight: bold;
282+
// The key is the label the row is identified by, so it keeps its line
283+
// and the value wraps around it.
284+
flex-shrink: 0;
263285
}
264286
&-value {
265287
color: var(--control-color);
288+
// See the note above: wrap rather than overflow, and break a single
289+
// over-long token rather than let it escape the panel.
290+
min-width: 0;
291+
overflow-wrap: break-word;
266292
}
267293
&-actions {
268294
flex-shrink: 0;

0 commit comments

Comments
 (0)