Skip to content

Commit d17a80f

Browse files
authored
[Discover] Add wrapping to field list on sidebar (#71312) (#71897)
1 parent c184115 commit d17a80f

3 files changed

Lines changed: 23 additions & 29 deletions

File tree

src/plugins/discover/public/application/components/sidebar/discover_field.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919
import React from 'react';
20-
import { EuiButton, EuiText } from '@elastic/eui';
20+
import { EuiButton } from '@elastic/eui';
2121
import { i18n } from '@kbn/i18n';
2222
import { DiscoverFieldDetails } from './discover_field_details';
2323
import { FieldIcon } from '../../../../../kibana_react/public';
@@ -108,6 +108,13 @@ export function DiscoverField({
108108
}
109109
};
110110

111+
function wrapOnDot(str?: string) {
112+
// u200B is a non-width white-space character, which allows
113+
// the browser to efficiently word-wrap right after the dot
114+
// without us having to draw a lot of extra DOM elements, etc
115+
return str ? str.replace(/\./g, '.\u200B') : '';
116+
}
117+
111118
return (
112119
<>
113120
<div
@@ -124,15 +131,12 @@ export function DiscoverField({
124131
scripted={field.scripted}
125132
/>
126133
</span>
127-
<span className="dscSidebarField__name eui-textTruncate">
128-
<EuiText
129-
size="xs"
130-
data-test-subj={`field-${field.name}`}
131-
className="eui-textTruncate"
132-
title={field.name}
133-
>
134-
{useShortDots ? shortenDottedString(field.name) : field.displayName}
135-
</EuiText>
134+
<span
135+
data-test-subj={`field-${field.name}`}
136+
title={field.name}
137+
className="dscSidebarField__name"
138+
>
139+
{useShortDots ? wrapOnDot(shortenDottedString(field.name)) : wrapOnDot(field.displayName)}
136140
</span>
137141
<span>
138142
{field.name !== '_source' && !selected && (

src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@
2323
margin-bottom: 0;
2424
}
2525

26-
.dscFieldList--selected,
27-
.dscFieldList--unpopular,
28-
.dscFieldList--popular {
29-
padding-left: $euiSizeS;
30-
padding-right: $euiSizeS;
31-
}
32-
3326
.dscFieldListHeader {
3427
padding: $euiSizeS $euiSizeS 0 $euiSizeS;
3528
background-color: lightOrDarkTheme(tint($euiColorPrimary, 90%), $euiColorLightShade);
@@ -40,8 +33,7 @@
4033
}
4134

4235
.dscFieldChooser {
43-
padding-left: $euiSizeS !important;
44-
padding-right: $euiSizeS !important;
36+
padding-left: $euiSize;
4537
}
4638

4739
.dscFieldChooser__toggle {
@@ -55,12 +47,12 @@
5547
display: flex;
5648
align-items: center;
5749
justify-content: space-between;
58-
padding: 0 2px;
5950
cursor: pointer;
6051
font-size: $euiFontSizeXS;
6152
border-top: solid 1px transparent;
6253
border-bottom: solid 1px transparent;
6354
line-height: normal;
55+
margin-bottom: $euiSizeXS * 0.5;
6456

6557
&:hover,
6658
&:focus {
@@ -72,28 +64,25 @@
7264

7365
.dscSidebarItem--active {
7466
border-top: 1px solid $euiColorLightShade;
75-
background: shade($euiColorLightestShade, 5%);
7667
color: $euiColorFullShade;
77-
.euiText {
78-
font-weight: bold;
79-
}
8068
}
8169

8270
.dscSidebarField {
83-
padding: $euiSizeXS 0;
71+
padding: $euiSizeXS;
8472
display: flex;
85-
align-items: flex-start;
73+
align-items: center;
8674
max-width: 100%;
87-
margin: 0;
8875
width: 100%;
8976
border: none;
90-
border-radius: 0;
77+
border-radius: $euiBorderRadius - 1px;
9178
text-align: left;
9279
}
9380

9481
.dscSidebarField__name {
9582
margin-left: $euiSizeS;
9683
flex-grow: 1;
84+
word-break: break-word;
85+
padding-right: 1px;
9786
}
9887

9988
.dscSidebarField__fieldIcon {

src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import './discover_sidebar.scss';
2020
import React, { useCallback, useEffect, useState, useMemo } from 'react';
2121
import { i18n } from '@kbn/i18n';
22-
import { EuiButtonIcon, EuiTitle } from '@elastic/eui';
22+
import { EuiButtonIcon, EuiTitle, EuiSpacer } from '@elastic/eui';
2323
import { sortBy } from 'lodash';
2424
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
2525
import { DiscoverField } from './discover_field';
@@ -199,6 +199,7 @@ export function DiscoverSidebar({
199199
/>
200200
</h3>
201201
</EuiTitle>
202+
<EuiSpacer size="xs" />
202203
<ul
203204
className="dscSidebarList dscFieldList--selected"
204205
aria-labelledby="selected_fields"

0 commit comments

Comments
 (0)