-
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
[input controls] update dropdown suggestions when filtered #18985
Conversation
cc @AlonaNadler |
💚 Build Succeeded |
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.
LGTM w/ possible tweaks
controlIndex={index} | ||
stageFilter={this.props.stageFilter} | ||
fetchOptions={async (query) => { return await this.props.refreshControl(index, query); }} | ||
/> |
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.
In this case, the caller of fetchOptions
is doing an await, so you can make this query => this.props.refreshControl(index, query)
since the caller is handling a promise anyway.
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.
Er. Also, I wonder if we can get rid of props.refreshControl
altogether, and just do query => control.fetch(query)
here, and allow the base Control to intelligently refresh when a query completes? Not sure. I don't know enough about this.
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 is no good way to update control in this component since it's state is passed in as props.
const resp = await searchSource.fetch(); | ||
if (query && this.lastQuery !== query) { | ||
// search results returned out of order - ignore results from old query | ||
return; |
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.
Seems this could accidentally blank out the results:
- fetch is called twice ('a', 'b')
- 'b' returns first
- 'a' returns second, and, and fetch returns undefined
The caller of fetch needs to know that if it gets an undefined, it should do nothing (it should keep its current state). Might be better to have this return the correct results if called out of sync (e.g. in the previous example, 'a' would return 'b's results).
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.
The return is not used to set anything. The resp
is used to update this.selectOptions
later in the function. Calling return early just short circuits so that this.selectOptions
is not updated with no longer needed data.
💚 Build Succeeded |
Chatted offline with @nreese about some feedback:
Some random ideas:
|
💔 Build Failed |
@nreese - going to hold off on further review until you investigate that bug with searching on ip field. Just lmk when ready to go for a second look. |
Here is some text to consider: Multiselect -> Allow multiple selection Dynamic Options -> Update options in response to user input Size -> Number of options |
💔 Build Failed |
Thanks @nreese just played with that and it looks great! |
…ssion when fetching agg results
Turns out that
returns
I tried using filters for non-string fields and that did not work either.
just returns
Looks like this option will only be available for String fields. |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
blocked on elastic/eui#947 |
…ted and only display dynamic checkbox when field is string
💚 Build Succeeded |
💚 Build Succeeded |
@stacey-gammon This is finally ready for review. Now the dynamic options checkbox is only visible for string fields. When checked, size is not allowed to be set. |
What do you think about making it visible but disabled with a tooltip explanation for non-string fields? Just because I envision answering discuss tickets "why can't I see this option with this field". cc @elastic/kibana-design . |
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.
small suggestion about the UI and the matching, but otherwise lgtm. Did a code review and pulled code and played around with searching the field values on the visualize app with both dynamic options turned on and off.
@@ -45,6 +51,11 @@ const termsAgg = (field, size, direction) => { | |||
} else { | |||
terms.field = field.name; | |||
} | |||
|
|||
if (query) { | |||
terms.include = `${getEscapedQuery(query)}.*`; |
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.
What do you think about .*${getEscapedQuery(query)}.*
so it searches the middle of the word too, not just a prefix? Esp since thats how it works when you use the size option.
💔 Build Failed |
💚 Build Succeeded |
…8985) * input controls - re-fetch options list user input * fix jest tests * add functional test case * remove unneeded async and await * use fetchAsRejectablePromise instead of fetch to avoid kill kibana session when fetching agg results * only show options once field is selected * clean up list control editor to only display options when field selected and only display dynamic checkbox when field is string * do not use size when using dynamic options * display disabled toggle when field is not string field, allow searching in middle of word * no tooltip for disabled dyncamic options, just change help text * fix functional test expects since search now includes more than terms that start with
…20604) * input controls - re-fetch options list user input * fix jest tests * add functional test case * remove unneeded async and await * use fetchAsRejectablePromise instead of fetch to avoid kill kibana session when fetching agg results * only show options once field is selected * clean up list control editor to only display options when field selected and only display dynamic checkbox when field is string * do not use size when using dynamic options * display disabled toggle when field is not string field, allow searching in middle of word * no tooltip for disabled dyncamic options, just change help text * fix functional test expects since search now includes more than terms that start with
fixes #17758 and #14529
PR adds new configuration
Dynamic Options
. When set to true, the dropdown options list is updated and filtered by the user input.