-
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
[Lens] Add loading indicator during debounce time #80158
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx
Outdated
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.
The behavior does work as expected, but I have a suggestion for a different way of organizing the code.
@@ -135,10 +141,13 @@ const SuggestionPreview = ({ | |||
data-test-subj="lnsSuggestion" | |||
onClick={onSelect} | |||
> | |||
{preview.expression && currentExpression !== renderedExpression && ( | |||
<EuiProgress size="xs" color="accent" position="absolute" /> | |||
)} |
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 agree that this approach works, but does it need to be Lens-specific? What if we supported a debouncing parameter on the ExpressionRenderer
component which would handle this automatically? The main reason I'm suggesting this is that the ExpressionRenderer
component is already responsible for showing both an EuiProgress
and <EuiLoadingChart size="m" />
, and it might be easy to share the logic.
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.
@elastic/kibana-app-arch what do you think about having a “debounce” parameter on the expression renderer component basically replicating this logic one layer deeper? The use case here is to not re-render the suggestions too often while the user interacts with the config, but still show an indication the current state will be updated soon.
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 see a problem with introducing debounce parameter to expression renderer 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.
Thanks Peter, I will move the logic over on this PR
I moved the logic for debouncing into the react expression renderer component. |
Huh, I thought the react hooks package was already part of the bundle. I will look into a replacement |
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.
Code LGTM, tested locally in Lens. I don't think there are any uses of this component outside Lens.
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.
Did not test since my last review, but I'm surprised about the react-use
issue.
- Lens and other plugins are already importing
react-use
- APM is importing it via
import useDebounce from 'react-use/lib/useDebounce';
- Ingest manager has a custom definition of
useDebounce
separately from these
I'm fine with the choice to define an effect instead of increasing the import size, but I wonder if it would be simpler to accept the entire react-use
package as a shared dependency.
@elasticmachine merge upstream |
@wylieconlon I considered something along those lines, but it's not super straight forward, that's why I opted for the inline implementation:
For this use case I'm in favor of proceeding with the inline implementation as it's really straight forward and easy to read. |
💚 Build SucceededMetrics [docs]async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
@wylieconlon I've created an issue: #80181 |
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.
app-arch debounce code changes LGTM
didn't test
Issue for addressing react-use: #80181
This PR adds a loading indicator to the suggestions during the debounce time so they don't look stale
Old:
![lagging_suggestions](https://user-images.githubusercontent.com/1508364/95752732-c38c8900-0ca0-11eb-81d0-cf1f8c15f638.gif)
New:
![up_to_date_suggestions](https://user-images.githubusercontent.com/1508364/95752744-ca1b0080-0ca0-11eb-9b45-3ce544f2ebe5.gif)