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

Multi-line kql bar #70140

Merged
merged 29 commits into from
Jul 8, 2020
Merged

Multi-line kql bar #70140

merged 29 commits into from
Jul 8, 2020

Conversation

snide
Copy link
Contributor

@snide snide commented Jun 27, 2020

Summary

Fixes #36140

Makes the kql bar use a textarea isntead of a text input. Does some juggling to manage the focus state and change the height dynamically as people edit long form queries. Also hides Discover's date picker when the query bar is focused. The later change requires the need to no longer auto focus the query bar, which seems like an acceptable trade off.''

Focus hides the date picker

textfocus

Content can now wrap multiple lines. The height adjusts appropriately

textcontent

Tests

Dunno what would need to be added test wize. This should be a pretty simple change from an interface level. If there are tests to be added, I'll likely need help from engineering.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@kertal kertal added the Feature:Discover Discover Application label Jun 30, 2020
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

This is pretty slick and overall I think a good solution for long queries.

A couple things that I found:

  1. The whole input steals the up/down arrow keys for traversing the auto-complete dropdown. Kind of annoying when you have more than one line. Is it possible to check if the auto-complete is open before steeling the up/down arrow keys?
  2. Should the enter key also collapse the input? Maybe moves the focus to the "Update" button?
  3. Tabbing out of the input doesn't reduce the width back. Meaning, the time picker doesn't come back when you tab to it.
  4. Super minor, but there's an interesting spacing difference between the date/picker and the Update button versus when the Kquery bar is fully open.
    Screen Recording 2020-06-30 at 11 15 AM
    Don't mind the styles, I am in the K8 theme and didn't want to switch back yet
  5. There's just a slight weirdness with the right border. Maybe the KQL button also needs a border to keep it separate from the cut off text.

Image 2020-06-30 at 11 21 42 AM

@snide
Copy link
Contributor Author

snide commented Jun 30, 2020

All good feedback. I think I can solve most of them. The up/down one is interesting.

@cchaos
Copy link
Contributor

cchaos commented Jun 30, 2020

Yeah I think it would just be moving the preventDefault() here into the if (isSuggestionsVisible) block.

case KEY_CODES.DOWN:
event.preventDefault();
if (isSuggestionsVisible && index !== null) {
this.incrementIndex(index);
} else {
this.setState({ isSuggestionsVisible: true, index: 0 });
}
break;

@snide snide requested review from a team as code owners June 30, 2020 17:19
@snide
Copy link
Contributor Author

snide commented Jun 30, 2020

@cchaos I think I got all your issues. Here's a vid so you don't need to pull it down. https://snid.es/2020JUN/eJ00p18NjH5jOQ48.mp4

Comment on lines +270 to +271
// Note to engineers. `isSuggestionVisible` does not mean the suggestions are visible.
// This should likely be fixed, it's more that suggestions can be shown.
Copy link
Contributor Author

@snide snide Jun 30, 2020

Choose a reason for hiding this comment

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

@XavierM @spong

I HIGHLY suggest taking a look at the state changes in this code when you run through here. At best this state is improperly named. isSuggestionsVisible is more accurately "mightHaveSuggestions". There are times when it is true when the dropdown suggestions are not actually visible. My guess is that no suggestions are present, so nothing renders. So again, "mightHaveSuggestions" seems more accurate.

My logic works, but I wouldn't be suprised if the next person who reads this code will likely run into an hour of headscratching like I did trying to figure out what is wrong.

I did not change anything here related to the state change, because this is a big codebase and I didn't want to muck it up, but one of you should check it out. I could only diagnose the problem by adding a bunch of console logs and seeing how the state changed in various keyEvents

@snide
Copy link
Contributor Author

snide commented Jun 30, 2020

This is done on the design code / functionality side. I'm passing this over to @XavierM to fix the tests (it has to do with value/child changes now that it's a textarea). Please let me know before Friday if you notice errors in the actual functionality as I'll be gone the two weeks before FF.

@XavierM XavierM removed the Feature:Discover Discover Application label Jul 1, 2020
@XavierM
Copy link
Contributor

XavierM commented Jul 1, 2020

This is done on the design code / functionality side. I'm passing this over to @XavierM to fix the tests (it has to do with value/child changes now that it's a textarea). Please let me know before Friday if you notice errors in the actual functionality as I'll be gone the two weeks before FF.

Thanks a lot, @snide, I hope that this commit 7ce67a9 will make everything green for us. If not I will come back to it ;)

@snide
Copy link
Contributor Author

snide commented Jul 1, 2020

@elasticmachine merge upstream

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

While playing around with the feature, I managed to get to a state where instead of expanding, the text area showed a scroll bar.

Is this OK?

image

@lizozom
Copy link
Contributor

lizozom commented Jul 6, 2020

@snide
Seems like we need a auto sizing text area for #24647 too, why don't we add an autosize option to EUI? See this as an example https://www.jacklmoore.com/autosize/

@randomuserid
Copy link
Contributor

randomuserid commented Jul 6, 2020

While playing around with the feature, I managed to get to a state where instead of expanding, the text area showed a scroll bar.

Is this OK?

image

I think if there were a scroll bar people would still copy & paste between an editor in order to be able to see the search when there is branching or complex logic or a long series of tests.

@cchaos
Copy link
Contributor

cchaos commented Jul 6, 2020

@lizozom There is a WIP PR for adding this behavior directly to EuiTextarea, but there's a lot more to it than this "simpler" version because of all the permutations EuiTextarea supports. Eventually it'll get picked back up, but not before 7.9.

@XavierM XavierM requested a review from lizozom July 6, 2020 18:39
@XavierM
Copy link
Contributor

XavierM commented Jul 7, 2020

@elasticmachine merge upstream

@XavierM
Copy link
Contributor

XavierM commented Jul 7, 2020

@elasticmachine merge upstream

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

Tested and working well now.
Also resolved merge conflicts 🙇

@XavierM
Copy link
Contributor

XavierM commented Jul 8, 2020

@elasticmachine merge upstream

@XavierM
Copy link
Contributor

XavierM commented Jul 8, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

History

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

@XavierM XavierM merged commit c815c96 into elastic:master Jul 8, 2020
XavierM added a commit to XavierM/kibana that referenced this pull request Jul 8, 2020
* Multiline kql bar

* fix id

* use visibility rather than display to hide stuff, cross fingers for tests

* another vis trick for tests

* quasi fix tests, still some failures

* caroline feedback

* fun!

* fix for mouse

* fix test

* check api

* fix unit test on query_string_input

* Fix cypress test

* handle the resize of the height of the textarea when the window have been resize

Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Liza K <liza.katz@elastic.co>
XavierM added a commit that referenced this pull request Jul 8, 2020
* Multiline kql bar

* fix id

* use visibility rather than display to hide stuff, cross fingers for tests

* another vis trick for tests

* quasi fix tests, still some failures

* caroline feedback

* fun!

* fix for mouse

* fix test

* check api

* fix unit test on query_string_input

* Fix cypress test

* handle the resize of the height of the textarea when the window have been resize

Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Liza K <liza.katz@elastic.co>

Co-authored-by: Dave Snider <dave.snider@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Liza K <liza.katz@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enlarge the search input field to support security use cases
8 participants