Skip to content

[Discover] Add row height options#122087

Merged
kertal merged 36 commits intoelastic:mainfrom
dimaanj:add-row-height-options
Feb 2, 2022
Merged

[Discover] Add row height options#122087
kertal merged 36 commits intoelastic:mainfrom
dimaanj:add-row-height-options

Conversation

@dimaanj
Copy link
Copy Markdown
Contributor

@dimaanj dimaanj commented Dec 28, 2021

Summary

Closes #109107

This PR adds ability to change row height options of Document explorer.

⚠️ Current PR still contains one small issue related to Eui component. Once user change rowHeight using toolbar, updating rowHeight from URL will not work.

Priority for applying rowHeight

  1. URL state
  2. Saved search
  3. Last used value (localStorage) or advanced setting (uiSettings)

4658636B-6136-4267-BFE1-976E445CE7D0_4_5005_c

7052D314-E3C2-47F5-9336-5661D1584F3A_4_5005_c

C7A60039-EC37-48AC-B974-DB5115671B7B_4_5005_c

Checklist

Delete any items that are not applicable to this PR.

@dimaanj dimaanj added Feature:Discover Discover Application release_note:feature Makes this part of the condensed release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.2.0 labels Dec 28, 2021
@dimaanj dimaanj self-assigned this Dec 28, 2021
@dimaanj
Copy link
Copy Markdown
Contributor Author

dimaanj commented Jan 3, 2022

@elasticmachine merge upstream

@dimaanj dimaanj marked this pull request as ready for review January 4, 2022 07:40
@dimaanj dimaanj requested review from a team as code owners January 4, 2022 07:40
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@kertal kertal requested a review from a team January 5, 2022 06:20
@kertal kertal added v8.1.0 and removed v8.2.0 labels Jan 5, 2022
@kertal
Copy link
Copy Markdown
Member

kertal commented Jan 5, 2022

@elasticmachine merge upstream

Copy link
Copy Markdown
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started testing and I'm excited that we will soon support this long awaited functionality in Discover. Sharing my thoughts while testing:

I think default Density should be normal, and we should add this value to local storage, so users don't have to reconfigure it every time. for me it looks a bit buggy when switching e.g. to Expanded in Safari (Chrome seems to be fine):
Bildschirmfoto 2022-01-05 um 08 52 38

  • Via the URL I was able to configure invalid states like -1 , also 10000, so we need better validation here

  • There's a difference in the way what's being displayed when selecting Single or Custom set to 1
    Bildschirmfoto 2022-01-05 um 09 17 13
    In the current way this is implemented we can't store single, since a given row height of 1 is automatically assumed to be a custom height of 1, asking @elastic/kibana-design for feedback if we should also support single, in this case we would need to rethink the way we handle persistence in state and saved object.

if we would need to support single we could do it the following way mapping to integers
-1 : auto height
0: single
1: custom 1
2: custom 2
.....

@andreadelrio
Copy link
Copy Markdown
Contributor

andreadelrio commented Jan 5, 2022

In the current way this is implemented we can't store single, since a given row height of 1 is automatically assumed to be a custom height of 1, asking @elastic/kibana-design for feedback if we should also support single, in this case we would need to rethink the way we handle persistence in state and saved object.

I think given that 1 is the default value for Custom, Single might not be needed. If we do want to support Single (as it might be a frequently needed setting) I would suggest we make 2 the default value for Custom as seen in the DataGrid's EUI docs examples.

@andreadelrio
Copy link
Copy Markdown
Contributor

I think default Density should be normal, and we should add this value to local storage, so users don't have to reconfigure it every time.

+1. I also think Normal should be the default, seems readability is better and perhaps matches Legacy more closely.

We currently have an issue with the font sizes when we display the whole document (i.e. no columns have been added). The EuiDataGrid styles are overridden by EuiDescriptionList's styles and I think we should address this. See:

Frame 81

Also when changing the Density there's an issue with the padding next to the checkbox to select documents.
Frame 85

For the expand/minimize icons it would be nice if for Expanded density we could do EuiButtonIcon with iconSize "m".

@kertal
Copy link
Copy Markdown
Member

kertal commented Jan 11, 2022

I think default Density should be normal, and we should add this value to local storage, so users don't have to reconfigure it every time.

+1. I also think Normal should be the default, seems readability is better and perhaps matches Legacy more closely.

We currently have an issue with the font sizes when we display the whole document (i.e. no columns have been added). The EuiDataGrid styles are overridden by EuiDescriptionList's styles and I think we should address this. See:

@andreadelrio Yes, we should fix the mixtures of font-sizes. But I think we should stick to a single size, and that's the size that's being displayed when choosing compact. When I look at the expanded view, especially with the Document column the font size is very large compared to the rest of the page.
Bildschirmfoto 2022-01-11 um 09 16 53
Personally, if I wanted a larger font size I'd rather use the browsers zoom functionality, to enlarge the whole page. So for me density shouldn't modify font size, but just padding. This matches better to the classic way.

@dmitriynj
Like Adrea mentioned the expand and selection columns should be fixed when using Normal & Expanded

Comment on lines +247 to +249
name: i18n.translate('discover.advancedSettings.params.rowHeightTitle', {
defaultMessage: 'Maximum lines of document explorer cell',
}),
Copy link
Copy Markdown
Member

@kertal kertal Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest switching to
Displayed lines of document explorer cell
FYI @gchaps

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like @gchaps suggested this should be changed into Row height in the Document Explorer

category: ['discover'],
description: i18n.translate('discover.advancedSettings.params.rowHeightText', {
defaultMessage:
'The maximum lines that a cell in a table should occupy. Auto height might be enabled by setting value to -1. Single option could be enabled by setting value to 0.',
Copy link
Copy Markdown
Member

@kertal kertal Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to change to
Displayed lines of a document explorer's cell. Auto height can be enabled by setting the value to -1. The explorer's single option can be enabled by setting value to 0.
FYI @gchaps

Copy link
Copy Markdown
Contributor

@gchaps gchaps Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kertal In looking at other documents, the term "row height" seems to be appropriate here. It's also the word you use in the pop-up. Here is a suggestion:

Row height in the Document Explorer
The number of lines to allow in a row. A value of -1 automatically adjusts the row height to fit the contents. A value of 0 displays the content in a single line.

I'm a little confused over the term Single and whether it is the same as setting Custom to 1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gchaps sounds good, yes "single". Thing is you can configure the height in the explorer to show just 1 line in 2 ways. Either you could choose Single or Custom with a height of 1. They look a bit different in terms of truncation, and work differently under the hood

@andreadelrio
Copy link
Copy Markdown
Contributor

andreadelrio commented Jan 19, 2022

@andreadelrio sounds good, question is if we should wait for elastic/eui#5526 to land in Kibana, which means, merge, once both is available, let's discuss it in our weekly

I think we're ok to wait for both to be available. I'll make sure to follow up to have mine approved asap.

…-height-options

# Conflicts:
#	src/plugins/discover/public/application/context/context_app.test.tsx
#	src/plugins/discover/public/application/main/components/layout/discover_documents.test.tsx
#	src/plugins/discover/public/application/main/components/layout/discover_layout.test.tsx
#	src/plugins/discover/public/components/discover_grid/discover_grid.test.tsx
#	src/plugins/discover/public/components/discover_grid/discover_grid.tsx
#	src/plugins/discover/public/embeddable/saved_search_grid.tsx
@kertal
Copy link
Copy Markdown
Member

kertal commented Jan 31, 2022

@elasticmachine merge upstream

@andreadelrio
Copy link
Copy Markdown
Contributor

@dmitriynj thanks for the updates, it is looking better. Wanted to check why content seems to be getting cut off when setting a custom # of lines? See below for the 3 lines case:

image

@kertal
Copy link
Copy Markdown
Member

kertal commented Feb 1, 2022

@dmitriynj thanks for the updates, it is looking better. Wanted to check why content seems to be getting cut off when setting a custom # of lines? See below for the 3 lines case:

image

I think I know why, when you disable the following in the browser it works:
Bildschirmfoto 2022-02-01 um 09 12 40
But I don't know how to disable it permanently?

Copy link
Copy Markdown
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, great work! Tested remote using Firefox, Safari, Edge, Chrome. Works as expected with the following limitations:

  • As mentioned in the description, once row height is changed locally, this state can't be overwritten by URL state, this should be fixed on EUI level

  • As discussed when showing the Document column with a certain number of lines, the last line gets cut off, this will high likely be a CSS fix somewhere? @andreadelrio

  • The reset to default makes no sense for our case, but that's also an EUI issue https://user-images.githubusercontent.com/463851/152003576-34d283c2-c413-44d8-8353-9ff2c554e244.mp4

  • And since we now display the loading state when loading a saved search, I encountered that when loading e.g. an e-commerce saved search followed by a flights saved search, when navigating back using the browsers back button, the loading state is displayed twice and also data is requested twice ... one load is triggered because the index pattern of the url changes, the other because of the change of the saved search. It shows a weakness of our current state handling, shouldn't be a blocker, but we should improve it.

All in all, don't think any of this should block us from merging, but of course we should fix those issues. We want flags, cats, dogs with flexible height in the Document explorer!
Bildschirmfoto 2022-02-01 um 16 31 17

@andreadelrio
Copy link
Copy Markdown
Contributor

andreadelrio commented Feb 1, 2022

I was looking at a CSS override for the line-height but I think a cleaner way to solve this is using EuiDataGrid settings, so I've set lineHeight in EuiDataGridRowHeightsOptions. See the result below:

Full doc, 3 lines per row:
image

Table with columns:
image 2

@kertal @dmitriynj let me know what you think and if there are any risks with this approach.

Copy link
Copy Markdown
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Andrea contributed, and I've verified locally, going ahead with an approval from design. This looks really nice, great work!

@kertal
Copy link
Copy Markdown
Member

kertal commented Feb 2, 2022

@elasticmachine merge upstream

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 368 371 +3

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
discover 62 65 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 334.0KB 335.4KB +1.4KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
discover 51.7KB 51.8KB +123.0B

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/development-plugin-saved-objects.html#_mappings

id before after diff
search 12 13 +1
Unknown metric groups

API count

id before after diff
discover 90 93 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @dmitriynj

@kertal kertal merged commit a7e0171 into elastic:main Feb 2, 2022
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Feb 2, 2022
@kertal
Copy link
Copy Markdown
Member

kertal commented Feb 2, 2022

@andreadelrio it's a nice solution, and no hack 👍 thx so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Discover Discover Application release_note:feature Makes this part of the condensed release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discover] Allow switching height of rows in data grid

9 participants