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] Allows users to not render suggestions #115946

Merged
merged 8 commits into from
Nov 2, 2021

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Oct 21, 2021

Summary

Closes #85518

This PR gives the users the ability to not render the suggestions.
The accordion status value is stored in localeStorage with the key LENS_SUGGESTIONS_PANEL_HIDDEN.

Note: When it is hidden, I don't send the search request so it could also be a performance improvement.

image

Checklist

@stratoula
Copy link
Contributor Author

@MichaelMarcialis I want your feedback here!
First of all I used a switch but if you were thinking another component please let me know!
Secondly I wanted to give a transition to hiding and showing the panel. This is the reason that I am playing with max-height and the opacity (as on the display property we can't add transition and the result is not so smooth). How do you feel about it?

@MichaelMarcialis
Copy link
Contributor

@MichaelMarcialis I want your feedback here!
First of all I used a switch but if you were thinking another component please let me know!
Secondly I wanted to give a transition to hiding and showing the panel. This is the reason that I am playing with max-height and the opacity (as on the display property we can't add transition and the result is not so smooth). How do you feel about it?

My first instinct would be to try using an EuiAccordion component here instead. That component already has show/hide transitions baked-in. Also, I believe that the accordion UI pattern makes more sense for such show/hide interactions.

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -264,8 +264,10 @@ describe('suggestion_panel', () => {
preloadedState,
});

expect(instance.find(EuiIcon)).toHaveLength(1);
expect(instance.find(EuiIcon).prop('type')).toEqual(LensIconChartDatatable);
expect(instance.find('[data-test-subj="lnsSuggestionsPanel"]').find(EuiIcon)).toHaveLength(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to be more specific here as EuiAccordion introduces another EuiIcon component.

@stratoula
Copy link
Contributor Author

@MichaelMarcialis great idea! It worked like a charm :)

@stratoula stratoula added Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.1.0 release_note:enhancement labels Oct 27, 2021
@stratoula stratoula marked this pull request as ready for review October 27, 2021 16:41
@stratoula stratoula requested review from a team as code owners October 27, 2021 16:41
@elasticmachine
Copy link
Contributor

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

@@ -293,6 +296,15 @@ export function SuggestionPanel({
}, [ExpressionRendererComponent]);

const [lastSelectedSuggestion, setLastSelectedSuggestion] = useState<number>(-1);
// get user's selection from localStorage, this key defines if the suggestions panel will be hidden or not
const [hideSuggestions, setHideSuggestions] = useLocalStorage(
Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't tested yet, maybe there's no difference, but can you prevent the suggestion computation above based on this flag?
I would be interesting to check if it has a performance impact

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had looked into it but it wasn't so simple. I could also get another look if you want.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did some basic profiling with and without recomputing the suggestions even if hidden, and it does change much the performance. The expression evaluation is still the main bottleneck there, so strong opinion on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dej611 the biggest problem I see is this:

  if (suggestions.length === 0) {
    return null;
  }

When there are no suggestions then we don't display the suggestions panel. For example
image

if we don't compute them if the suggestions are hidden, how this will work? Can we use another variable? If yes, which?

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis 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 looking good, @stratoula! Left a few comments/questions for your review.

Comment on lines 23 to 25
.lnsSuggestionPanel--hideSuggestions {
padding-bottom: $euiSizeS;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than conditionally applying padding to the bottom of the suggestions panel, would it be better to just apply ever-present bottom padding to .lnsFrameLayout__pageBody? You'd likely also have to adjust or remove the padding from .lnsSuggestionPanel__suggestions as well, but I think that makes the organization and maintenance of the padding much simpler. What do you think?

Copy link
Contributor Author

@stratoula stratoula Nov 1, 2021

Choose a reason for hiding this comment

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

@MichaelMarcialis the reason I didn't do it this way, is because I saw this comment and didn't want to break anything :D

.lnsFrameLayout__pageBody {
  @include euiScrollBar;
  min-width: $lnsPanelMinWidth + $euiSizeXL;
  overflow: hidden auto;
  display: flex;
  flex-direction: column;
  flex: 1 1 100%;
  // Leave out bottom padding so the suggestions scrollbar stays flush to window edge
  // Leave out left padding so the left sidebar's focus states are visible outside of content bounds
  // This also means needing to add same amount of margin to page content and suggestion items**
  padding: $euiSize $euiSize 0;
  position: relative;
  z-index: $lnsZLevel1;

  &:first-child {
    padding-left: $euiSize;
  }

  &.lnsFrameLayout__pageBody-isFullscreen {
    background: $euiColorEmptyShade;
    flex: 1;
    padding: 0;
  }
}

But I removed the condition with this way:

  • removed the lnsSuggestionPanel--hideSuggestions
  • removed the padding from lnsSuggestionPanel__suggestions
  • added the padding on the container lnsSuggestionPanel
    Wdyt about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

That works. Thanks for looking into it!

Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

I did test locally with Chrome and Safari and all good 👍

Maybe the only minor feedback I can report is the use of the right arrow icon for the accordion feels weird, maybe it would look better as an arrow up? On click the content is rising up rather than pushing it down, which looks a bit different from classical accordion case.

hide_suggestions

Anyway approving to not block for that detail.

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Test Failures

  • [job] [logs] Default CI Group #6 / apis SecuritySolution Endpoints Matrix DNS Histogram Large data set Make sure that we get dns data without getting bucket errors when querying large volume of data

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 673 674 +1

Async chunks

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

id before after diff
lens 953.0KB 953.9KB +957.0B

History

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

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments. This LGTM!

@stratoula stratoula added the backport:skip This commit does not require backporting label Nov 2, 2021
@stratoula stratoula merged commit 29e807f into elastic:main Nov 2, 2021
@flash1293 flash1293 added v7.17.0 v8.0.0 and removed backport:skip This commit does not require backporting labels Jan 14, 2022
flash1293 pushed a commit to flash1293/kibana that referenced this pull request Jan 14, 2022
* [Lens] Allows users to not render suggestions

* Improve the transitions

* change implementation and use EuiAccordion instead

* Fixes the scrolling problem on the suggestions panel

* Apply PR comments

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 29e807f)

# Conflicts:
#	x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx
flash1293 pushed a commit to flash1293/kibana that referenced this pull request Jan 14, 2022
* [Lens] Allows users to not render suggestions

* Improve the transitions

* change implementation and use EuiAccordion instead

* Fixes the scrolling problem on the suggestions panel

* Apply PR comments

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 29e807f)
@flash1293
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.0
7.17

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

flash1293 added a commit that referenced this pull request Jan 14, 2022
* [Lens] Allows users to not render suggestions

* Improve the transitions

* change implementation and use EuiAccordion instead

* Fixes the scrolling problem on the suggestions panel

* Apply PR comments

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 29e807f)

# Conflicts:
#	x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx

Co-authored-by: Stratoula Kalafateli <[email protected]>
flash1293 added a commit that referenced this pull request Jan 14, 2022
* [Lens] Allows users to not render suggestions

* Improve the transitions

* change implementation and use EuiAccordion instead

* Fixes the scrolling problem on the suggestions panel

* Apply PR comments

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 29e807f)

Co-authored-by: Stratoula Kalafateli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Allow users to not render suggestions
6 participants