-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discover] In-table search #206454
[Discover] In-table search #206454
Conversation
…360-in-table-search
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/platform/packages/shared/kbn-data-grid-in-table-search/src/in_table_search_control.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think it is because it founds the number in hidden columns, this is a bit confusing tbh but I am not sure how we can make it better. Just mentioning it here for visibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if a match is cut off by the cell boundaries then it might be confusing. I added the yellow border to the active cell as a hint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jughosta thinking in how to solve this, could we move the content in the cell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, could we consider this issue as an edge case? not sure if users will find themselves in this situation too often 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think is an edge case tbh but is not something I consider as a blocker either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jughosta and I already discussed this limitation and it is not a blocker. Users have the ability to increase row height to see what is matching. Let's launch and collect feedback, if it is a big user pain and the workaround of increasing row height is not enough, then we can take it from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that it may not be an edge case, but also not a blocker. It's a tricky problem, collecting feedback is probably a good first step.
EUI offers a way to override row height for individual rows using the rowHeights
option. We may be able to temporarily override to auto
when highlighting a cell for "find" to ensure all matches are visible, and backport as a bug fix if it works well. Not sure how that would feel UX wise or if it's oversimplifying though, so just thinking out loud for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked by design - LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES|QL changes LGTM! I played with it in both Chrome and FF, works great. (I focused on the ES|QL mode and havent tested the dataview mode)
Great work Jul 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/functional/services/data_grid.ts
changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codewise we are only involved for shared ownership on the cell_actions_popover
, the rest has been deeply reviewed already.
I left a note regarding the change for the text truncation, but it's not a blocker as logically should work fine and I don't want to block this further.
...d/kbn-discover-contextual-components/src/data_types/logs/components/cell_actions_popover.tsx
Show resolved
Hide resolved
@@ -90,18 +91,28 @@ export const internalRenderCustomToolbar = ( | |||
<EuiFlexItem grow={false}> | |||
<EuiFlexGroup responsive={false} gutterSize="s" alignItems="center"> | |||
{Boolean(leftSide) && buttons} | |||
{(keyboardShortcutsControl || displayControl || fullScreenControl) && ( | |||
{Boolean( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: all the boolean calls for each of these can probably be done once in the body of the component and not the render,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, probably some opportunity for future cleanup in this component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really really awesome feature! Thank you. Will test out enabling this in security as well 😄
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
History
cc @jughosta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phew, that was a lot to get through and take in at once. But excellent work on this, and great creativity getting it to work for formatted values! A super useful feature, nicely encapsulated in a reusable package 👌 I also like how much you were able to test through RTL vs FTR (seems like there are plenty of tests too).
I tested locally as much as I could, and in the vast majority of cases it worked great! There was a significant performance/rendering hit when pushing the limits by searching 10,000 summary columns, but I imagine this is a rarer case, and it still eventually returned results without falling over. So definitely sufficient for an MVP, with some opportunity to investigate further optimizations later.
I left some comments, but mostly nits and questions, nothing blocking or that needs to be addressed immediately. Otherwise I just noticed a few things when testing that we should consider following up on:
- When using the native Chrome find, I can hold down Enter to cycle through matches, while in ours I have to tap repeatedly. It might polish the UX a bit if we did the same.
- When I was stepping through matches and encountered one that was truncated, I changed the row height, which triggered a new search and reset me back to 0. We might want to consider if it's possible to keep the user on their current match in this case.
- When stepping through matches and reaching the last page, loading more results also triggered a new search and reset me back to 0. Another case where it may be helpful to track the current match, but this seems like it could be trickier.
With that said, I'm merging this thing! 🎉
export const HIGHLIGHT_COLOR = '#e5ffc0'; // TODO: Use a named color token | ||
export const ACTIVE_HIGHLIGHT_COLOR = '#ffc30e'; // TODO: Use a named color token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a dedicated issue for tracking this and working with the EUI team to get the tokens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
const innerCss = css` | ||
.dataGridInTableSearch__matchesCounter { | ||
font-variant-numeric: tabular-nums; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious what this is doing? I've never used font-variant-numeric
before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davismcphee It allows to make numbers the same width (even if the font face is not monospaced) so there are no layout shifts when a digit changes.
|
||
.dataGridInTableSearch__input { | ||
/* to prevent the width from changing when entering the search term */ | ||
min-width: 210px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could use EUI size var here.
background: none; | ||
} | ||
|
||
/* override borders style only if it's under the custom grid toolbar */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could make sense to override in Unified Data Table instead if it's specific to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also specific to the current in-table search layout 😀
border: 2px solid ${ACTIVE_HIGHLIGHT_COLOR} !important; | ||
border-radius: 3px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I also wonder if there are / should be EUI vars available for these values.
@@ -90,18 +91,28 @@ export const internalRenderCustomToolbar = ( | |||
<EuiFlexItem grow={false}> | |||
<EuiFlexGroup responsive={false} gutterSize="s" alignItems="center"> | |||
{Boolean(leftSide) && buttons} | |||
{(keyboardShortcutsControl || displayControl || fullScreenControl) && ( | |||
{Boolean( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, probably some opportunity for future cleanup in this component.
@@ -993,11 +1031,15 @@ export const UnifiedDataTable = ({ | |||
renderCustomToolbar({ | |||
toolbarProps, | |||
gridProps: { | |||
additionalControls, | |||
additionalControls: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our toolbar logic is kinda confusing, and I wonder if we could standardize it more at some point to avoid all the conditionals. Not something for now though.
return null; | ||
} | ||
|
||
let prevJumpTimer: NodeJS.Timeout | null = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could sharing this reference potentially cause issues with multiple searchable grids on screen at once like in dashboards? Doesn't really seem like it from the code, but wanted to raise it regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially yes, it would cancel a jump inside one panel when a jump is triggered in another one. Not likely in reality as changing between panels would take longer when the jump itself.
Having the timeout helps with a flow when users presses prev/next buttons or the shortcut too quickly inside one panel. Less visual noise with the highlights.
const pageIndexRef = useRef<number>(); | ||
pageIndexRef.current = pagination?.pageIndex ?? 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another spot where useLatest
could come in handy.
const controlsCount = dataGridWrapper | ||
? dataGridWrapper.querySelectorAll('.euiDataGridHeaderCell--controlColumn').length | ||
: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would also be nice to have a cleaner way of knowing this, but again a minor concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I was in the mood of using querySelector
in many places here. So old school 😀
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `8.x`: - [[Discover] In-table search (#206454)](#206454) <!--- Backport version: 9.6.4 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-29T23:52:07Z","message":"[Discover] In-table search (#206454)\n\n- Closes https://github.com/elastic/kibana/issues/192360\r\n\r\n## Summary\r\n\r\nThe default browser Find-in-page does not work great with the grid\r\nvirtualization and our pagination and it can only find matches in rows\r\nwhich are currently displayed.\r\n\r\nThis PR adds in-table search support to the grid so users can find\r\nmatches in all grid rows (up to `500` sample docs/rows by default) and\r\njump between them with \"Previous\"/\"Next\" buttons.\r\n\r\n![Jan-24-2025\r\n22-03-54](https://github.com/user-attachments/assets/95b31fb8-4740-4c5f-ba91-8e1c19066e02)\r\n\r\nThe implementation is extracted in a new package\r\n`@kbn/data-grid-in-table-search`. This would allow to use in-table\r\nsearch with `EuiDataGrid` on other pages of Kibana too.\r\n\r\n`Cmd+F` shortcut is overridden when one of grid elements is in focus\r\notherwise we keep the browser default behaviour.\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: florent-leborgne <[email protected]>","sha":"8ffb2ff62830655587d2b91e295b5d76fc86806e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["v9.0.0","release_note:feature","Team:DataDiscovery","backport:prev-minor","Project:OneDiscover"],"title":"[Discover] In-table search","number":206454,"url":"https://github.com/elastic/kibana/pull/206454","mergeCommit":{"message":"[Discover] In-table search (#206454)\n\n- Closes https://github.com/elastic/kibana/issues/192360\r\n\r\n## Summary\r\n\r\nThe default browser Find-in-page does not work great with the grid\r\nvirtualization and our pagination and it can only find matches in rows\r\nwhich are currently displayed.\r\n\r\nThis PR adds in-table search support to the grid so users can find\r\nmatches in all grid rows (up to `500` sample docs/rows by default) and\r\njump between them with \"Previous\"/\"Next\" buttons.\r\n\r\n![Jan-24-2025\r\n22-03-54](https://github.com/user-attachments/assets/95b31fb8-4740-4c5f-ba91-8e1c19066e02)\r\n\r\nThe implementation is extracted in a new package\r\n`@kbn/data-grid-in-table-search`. This would allow to use in-table\r\nsearch with `EuiDataGrid` on other pages of Kibana too.\r\n\r\n`Cmd+F` shortcut is overridden when one of grid elements is in focus\r\notherwise we keep the browser default behaviour.\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: florent-leborgne <[email protected]>","sha":"8ffb2ff62830655587d2b91e295b5d76fc86806e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/206454","number":206454,"mergeCommit":{"message":"[Discover] In-table search (#206454)\n\n- Closes https://github.com/elastic/kibana/issues/192360\r\n\r\n## Summary\r\n\r\nThe default browser Find-in-page does not work great with the grid\r\nvirtualization and our pagination and it can only find matches in rows\r\nwhich are currently displayed.\r\n\r\nThis PR adds in-table search support to the grid so users can find\r\nmatches in all grid rows (up to `500` sample docs/rows by default) and\r\njump between them with \"Previous\"/\"Next\" buttons.\r\n\r\n![Jan-24-2025\r\n22-03-54](https://github.com/user-attachments/assets/95b31fb8-4740-4c5f-ba91-8e1c19066e02)\r\n\r\nThe implementation is extracted in a new package\r\n`@kbn/data-grid-in-table-search`. This would allow to use in-table\r\nsearch with `EuiDataGrid` on other pages of Kibana too.\r\n\r\n`Cmd+F` shortcut is overridden when one of grid elements is in focus\r\notherwise we keep the browser default behaviour.\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: florent-leborgne <[email protected]>","sha":"8ffb2ff62830655587d2b91e295b5d76fc86806e"}}]}] BACKPORT--> --------- Co-authored-by: Julia Rechkunova <[email protected]> Co-authored-by: kibanamachine <[email protected]>
Thanks for the review, @davismcphee! I created two tickets per your suggestions: |
Summary
The default browser Find-in-page does not work great with the grid virtualization and our pagination and it can only find matches in rows which are currently displayed.
This PR adds in-table search support to the grid so users can find matches in all grid rows (up to
500
sample docs/rows by default) and jump between them with "Previous"/"Next" buttons.The implementation is extracted in a new package
@kbn/data-grid-in-table-search
. This would allow to use in-table search withEuiDataGrid
on other pages of Kibana too.Cmd+F
shortcut is overridden when one of grid elements is in focus otherwise we keep the browser default behaviour.Checklist
release_note:breaking
label should be applied in these situations.release_note:*
label is applied per the guidelines