[Code] Search results are fixed to top of page (#45182) (#45425)

* Fix main search bar to top of screen

By allowing overflow on the main content, we implicitly fix the sibling
search bar in position.

elastic/code#1606

* Allow search suggestion text to be truncated

This gives the parent element a width, so that our text-overflow
rules apply to these elements.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1086218#c4 for details
on the issue.

* Fix alignment issue with overflowed search suggestions

If both the icon and the text are allowed to grow/shrink as needed,
flexbox will grow truncated text based on its original width, leading to
subtle sub-pixel alignment issues with other rows.

By fixing the icon to a specific width, we can ensure that the
suggestion text does not grow too big.

* Remove unneeded CSS

We don't need to flex these elements currently as they contain either no
children or inline elements only.

* style: prefer camelCase element names over hyphens

* Fix search result suggestion overflow on IE

Without this directive on the parent, it had no width or flex growth and
didn't respect the parent width. This allows it to take on the correct
flexed width, and thus take on the overflow rules.

* Remove unused CSS rule

We have an overriding align-items declaration immediately after this
one.
This commit is contained in:
Ryland Herrick 2019-09-11 16:32:17 -05:00 committed by GitHub
parent 4ab449f5bf
commit 487e04b62e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 20 deletions

View file

@ -165,18 +165,18 @@
.codeSearch-suggestion--inner {
display: flex;
align-items: stretch;
flex-grow: 1;
align-items: center;
white-space: nowrap;
}
.codeSearch__suggestionTextContainer {
min-width: 0;
flex: 1;
}
.codeSearch__suggestion-text {
color: $euiColorFullShade;
display: flex;
flex-direction: column;
flex-grow: 0;
flex-basis: auto;
font-family: $euiCodeFontFamily;
margin-right: $euiSizeXL;
width: auto;
@ -228,10 +228,6 @@
}
.codeSearch-suggestion__description {
flex-grow: 1;
flex-basis: 0%;
display: flex;
flex-direction: column;
color: $euiColorDarkShade;
overflow: hidden;
text-overflow: ellipsis;
@ -242,9 +238,7 @@
.codeSearch-suggestion__token {
color: $euiColorFullShade;
box-sizing: border-box;
flex-grow: 0;
flex-basis: auto;
width: $euiSizeXL;
flex: 0 0 $euiSizeXL;
height: $euiSizeXL;
text-align: center;
overflow: hidden;

View file

@ -30,7 +30,9 @@ exports[`render file item 1`] = `
<div
className="codeSearch-suggestion--inner"
>
<div>
<div
className="codeSearch__suggestionTextContainer"
>
<div
className="codeSearch__suggestion-text"
data-test-subj="codeTypeaheadItem"
@ -84,7 +86,9 @@ exports[`render repository item 1`] = `
<div
className="codeSearch-suggestion--inner"
>
<div>
<div
className="codeSearch__suggestionTextContainer"
>
<div
className="codeSearch__suggestion-text"
data-test-subj="codeTypeaheadItem"
@ -166,7 +170,9 @@ exports[`render symbol item 1`] = `
</div>
</EuiToken>
</div>
<div>
<div
className="codeSearch__suggestionTextContainer"
>
<div
className="codeSearch__suggestion-text"
data-test-subj="codeTypeaheadItem"

View file

@ -272,7 +272,9 @@ exports[`render full suggestions component 1`] = `
</div>
</EuiToken>
</div>
<div>
<div
className="codeSearch__suggestionTextContainer"
>
<div
className="codeSearch__suggestion-text"
data-test-subj="codeTypeaheadItem"
@ -404,7 +406,9 @@ exports[`render full suggestions component 1`] = `
<div
className="codeSearch-suggestion--inner"
>
<div>
<div
className="codeSearch__suggestionTextContainer"
>
<div
className="codeSearch__suggestion-text"
data-test-subj="codeTypeaheadItem"
@ -531,7 +535,9 @@ exports[`render full suggestions component 1`] = `
<div
className="codeSearch-suggestion--inner"
>
<div>
<div
className="codeSearch__suggestionTextContainer"
>
<div
className="codeSearch__suggestion-text"
data-test-subj="codeTypeaheadItem"
@ -575,7 +581,9 @@ exports[`render full suggestions component 1`] = `
<div
className="codeSearch-suggestion--inner"
>
<div>
<div
className="codeSearch__suggestionTextContainer"
>
<div
className="codeSearch__suggestion-text"
data-test-subj="codeTypeaheadItem"

View file

@ -71,7 +71,7 @@ export const SuggestionComponent: SFC<Props> = props => {
>
<div className="codeSearch-suggestion--inner">
{icon}
<div>
<div className="codeSearch__suggestionTextContainer">
<div className="codeSearch__suggestion-text" data-test-subj={`codeTypeaheadItem`}>
{renderMatchingText(props.suggestion.text)}
</div>

View file

@ -7,6 +7,7 @@
}
.codeContainer__adminMain {
overflow: auto;
padding: $euiSize $euiSizeXL;
}