-
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
[Infra and Logs UI] Fixes "sticky filter" problem #40226
[Infra and Logs UI] Fixes "sticky filter" problem #40226
Conversation
29d44eb
to
e09f75a
Compare
💔 Build Failed |
retest |
💔 Build Failed |
retest |
💔 Build Failed |
As I think about this more, I think maybe a better/more complete solution (down the road) is a debounced "as you type" submit, since we don't surface any kind of submit or "apply changes" button. |
retest |
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.
Pinging @elastic/infra-logs-ui |
@@ -156,6 +157,12 @@ export class AutocompleteField extends React.Component< | |||
case 'End': | |||
this.updateSuggestions(); | |||
break; | |||
case 'Backspace': | |||
// if the user has just deleted everything, submit to reset | |||
if (this.props.value === '') { |
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.
How about we move this to either the changeValue
method or even out of this component into the onChange
handler passed in? Then it wouldn't work for just the Backspace
key but also for delete or any other means of emptying the input.
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.
Good idea. Moving to changeValue
presented some race condition stuff where the changed state may not be updated and this.submit()
only uses the value
from this.props
, but we are already checking for the existence of a new value
prop in componentDidUpdate
so I moved it there and verified it all still works as expected (but now it also works if you "ctrl-x" cut, for example).
💚 Build Succeeded |
💔 Build Failed |
retest |
…lur to prevent sticky value problem
c15695d
to
9792de9
Compare
💚 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.
I haven't tested the whole thing thoroughly but the new empty value check location looks better 👍
* Submits query bar form when everything has been deleted and also on blur to prevent sticky value problem * Moved reset to cDU to cover all deleted value cases, not just Backspace
* Submits query bar form when everything has been deleted and also on blur to prevent sticky value problem * Moved reset to cDU to cover all deleted value cases, not just Backspace
Thank you @jasonrhodes and @weltenwort ! |
Closes #39991
Summary
The problem in this issue is caused by the fact that our autocomplete query bar only submits a value on enter. If you click out of the field without pressing "enter" first, your newest filter value won't be applied. This creates unexpected scenarios, especially when trying to delete existing filters (and especially when trying to delete existing filters that returned no results).
This PR fixes this issue in two ways.
First, if you have deleted all of the existing filters, the data will be re-queried automatically even before you exit the field or press enter. (This gives you your unfiltered data back as quickly as possible so you can begin to search again.)
Second, if you have more than one filter, the query will at least re-execute if you delete the "bad" filter and then exit the input, i.e. you click somewhere else rather than pressing "enter".