Skip to content
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

[Lens] Prevent KQL Popovers From Stacking #118258

Merged
merged 11 commits into from
Nov 17, 2021

Conversation

drewdaemon
Copy link
Contributor

@drewdaemon drewdaemon commented Nov 10, 2021

Summary

Fixes #105518 .

Does this by using the parent FilterList component to manage open/close popover state. This allows us to make sure that only one can be open at a time.

Screen.Recording.2021-11-10.at.3.07.31.PM.mov

@drewdaemon drewdaemon marked this pull request as ready for review November 11, 2021 17:41
@drewdaemon drewdaemon requested a review from a team as a code owner November 11, 2021 17:41
@drewdaemon drewdaemon added Feature:Lens release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Nov 11, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

@drewdaemon drewdaemon changed the title 105518/filter popovers can stack Prevent KQL Popovers From Stacking Nov 11, 2021
@flash1293
Copy link
Contributor

@elasticmachine merge upstream

@elastic elastic deleted a comment from kibanamachine Nov 15, 2021
@flash1293
Copy link
Contributor

Other popovers work fine now, but clicking the same button again doesn't close the popover anymore - seems like this worked accidentally before. Can we get this behavior back?
Kapture 2021-11-15 at 14 00 08

@drewdaemon
Copy link
Contributor Author

@flash1293 good catch. I've updated the PR to restore that behavior.

@drewdaemon drewdaemon requested a review from flash1293 November 15, 2021 18:29
@drewdaemon drewdaemon changed the title Prevent KQL Popovers From Stacking [Lens] Prevent KQL Popovers From Stacking Nov 15, 2021
@flash1293
Copy link
Contributor

Sorry, missed this during first review - to make it easy to use this via keyboard only, the focus should jump back to the "Add filter" button if the user presses enter in the KQL field in the popover:
old

However, on this PR it's jumping to the close button instead:
Kapture 2021-11-16 at 09 14 20

I'm not 100% sure why this happens - the logic to put the focus back to the last button is handled automatically by the EuiPopover - it stores a reference to the last focused element on opening, then on closing it tries to focus it again.

Maybe it's because the newly introduced effect takes an additional render cycle to get the "open" state to the filter popover? https://github.com/elastic/kibana/pull/118258/files#diff-2d0f89c22addaee8aa9d430ad3ae303df53874d506b65f1c820371c727b17cb1R182

On your PR the user presses the "Add filter" button, it adds the filter to the state, renders, sets the "activeFilterId" via the new effect hook, renders, then sets the actual popover open state in

https://github.com/elastic/kibana/pull/118258/files#diff-e127eadc5836b29048ab36c9a7f2cb28fe940484d66736e81cba2b5a092713b6R38

@mbondyra
Copy link
Contributor

mbondyra commented Nov 16, 2021

Good job with this PR, these things are really tricky! Apart from Joe's comment, there's two more issues:

  1. Could you also implement this behavior for interval ranges? It should be very similar as it uses similar components. The issue didn't mention that 🙈

Screenshot 2021-11-16 at 11 24 48

  1. This is not introduced by this PR, but when a user has a filter popover open and presses escape, it closes the popover and the flyout. Could you check if simple stopPropagation would stop the flyout from closing if popover is open?

@drewdaemon
Copy link
Contributor Author

@elasticmachine merge upstream

@drewdaemon
Copy link
Contributor Author

drewdaemon commented Nov 16, 2021

For the record, @flash1293 and I found that the focus bug is present on main as well as this branch, so these changes don't seem to be the culprit.

@mbondyra

Could you also implement this behavior for interval ranges?

Sure! Would you recommend I do that as part of this PR, or shall I create a separate issue?

but when a user has a filter popover open and presses escape, it closes the popover and the flyout. Could you check if simple stopPropagation would stop the flyout from closing if popover is open?

I see what you mean. I'll have a look.

@drewdaemon
Copy link
Contributor Author

drewdaemon commented Nov 16, 2021

@mbondyra it looks like the escape key behavior should be handled by EUI (see this PR). However, for some reason it isn't working, so I provided a stop-gap solution that you can review.

This makes me wonder if we've found two EUI bugs.

Edit: it looks like they're working on a major version bump right now #117242. Maybe this will resolve something...

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
lens 957.9KB 958.0KB +188.0B

History

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

@mbondyra
Copy link
Contributor

mbondyra commented Nov 17, 2021

Sure! Would you recommend I do that as part of this PR, or shall I create a separate issue?

As you prefer! I'm gonna approve this now and ask me for rereview in case if you choose to continue in this PR :)

The 'focus to close button' bug happens on 7.16 too so if you choose not to fix it here, please create an issue 🙏🏼

@drewdaemon drewdaemon merged commit c983bd9 into elastic:main Nov 17, 2021
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Nov 17, 2021
TinLe pushed a commit to TinLe/kibana that referenced this pull request Nov 20, 2021
@drewdaemon drewdaemon deleted the 105518/filter-popovers-can-stack branch November 22, 2021 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Lens release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Filters agg KQL dialog can stack
6 participants