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

[Dashboard] Fix Lens and TSVB chart tooltip positioning relative to global headers #94247

Merged
merged 14 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/core/public/rendering/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
min-height: 100%;
}

#app-fixed-viewport {
pointer-events: none;
visibility: hidden;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
}

.app-wrapper {
display: flex;
flex-flow: column nowrap;
Expand All @@ -35,6 +45,10 @@
@mixin kbnAffordForHeader($headerHeight) {
padding-top: $headerHeight;

#app-fixed-viewport {
top: $headerHeight;
}

.euiFlyout,
.euiCollapsibleNav {
top: $headerHeight;
Expand Down
1 change: 1 addition & 0 deletions src/core/public/rendering/rendering_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class RenderingService {
{chromeHeader}
<AppWrapper chromeVisible$={chrome.getIsVisible$()}>
<div className="app-wrapper-panel">
<div id="app-fixed-viewport" />
<div id="globalBannerList">{bannerComponent}</div>
<AppContainer classes$={chrome.getApplicationClasses$()}>{appComponent}</AppContainer>
Comment on lines +55 to 57
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the purpose, but I'm unsure why all this is necessary tbh. In 'stretch-to-height' mode apps, app-wrapper-panel (or even .kibana-body) already pretty much has the effective layout/positioning the added #app-fixed-viewport element has, isn't it?

Couldn't you just use .app-wrapper-panel or .kbnBody as your boundary element?

Copy link
Member

Choose a reason for hiding this comment

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

The .app-wrapper-panel and the #kibana-body` have a height of 100% of the entire dashboard and they scroll with the dashboard itself, using that as boundary doesn't block the tooltip from being blocked right below the headers.

Copy link
Contributor Author

@nickofthyme nickofthyme Mar 12, 2021

Choose a reason for hiding this comment

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

@markov00 is correct, I tried using every top-level element that was available including:

  • document.body or .kbn-body -- only at the top of the scroll height and moves when body is scrolled. See video below.
  • #kibana-body -- full scroll height goes beyond viewport as soon as you scroll
  • .content -- full scroll height goes beyond viewport as soon as you scroll
  • .app-wrapper -- full scroll height goes beyond viewport as soon as you scroll
  • .app-wrapper-panel -- full scroll height goes beyond viewport as soon as you scroll
  • .application -- full scroll height goes beyond viewport as soon as you scroll

You can see the height of these scroll elements on the video below being ~2500px.

This was the last option unless someone else has any suggestions.

Screen.Recording.2021-03-11.at.11.49.31.AM.mp4

Copy link
Contributor

Choose a reason for hiding this comment

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

The .app-wrapper-panel and the #kibana-body` have a height of 100% of the entire dashboard and they scroll with the dashboard itself

Oh, I thought it was for a stretch to height app. You're right, for dashboard, the body is taking the effective height of the dashboard.

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const TimeSeries = ({
tooltip={{
snap: true,
type: tooltipMode === 'show_focused' ? TooltipType.Follow : TooltipType.VerticalCursor,
boundary: document.getElementById('app-fixed-viewport') ?? undefined,
headerFormatter: tooltipFormatter,
}}
externalPointerEvents={{ tooltip: { visible: false } }}
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/vis_type_xy/public/components/xy_settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ export const XYSettings: FC<XYSettingsProps> = ({
: headerValueFormatter &&
(tooltip.detailedTooltip ? undefined : ({ value }: any) => headerValueFormatter(value));

const boundary = document.getElementById('app-fixed-viewport') ?? undefined;
const tooltipProps: TooltipProps = tooltip.detailedTooltip
? {
...tooltip,
boundary,
customTooltip: tooltip.detailedTooltip(headerFormatter),
headerFormatter: undefined,
}
: { ...tooltip, headerFormatter };
: { ...tooltip, boundary, headerFormatter };

return (
<Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export function PieComponent(

onClickValue(desanitizeFilterContext(context));
};

return (
<VisualizationContainer
reportTitle={props.args.title}
Expand All @@ -260,6 +261,7 @@ export function PieComponent(
>
<Chart>
<Settings
tooltip={{ boundary: document.getElementById('app-fixed-viewport') ?? undefined }}
debugState={window._echDebugStateFlag ?? false}
// Legend is hidden in many scenarios
// - Tiny preview
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/xy_visualization/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ export function XYChart({
const { legend, layers, fittingFunction, gridlinesVisibilitySettings, valueLabels } = args;
const chartTheme = chartsThemeService.useChartsTheme();
const chartBaseTheme = chartsThemeService.useChartsBaseTheme();

const filteredLayers = getFilteredLayers(layers, data);

if (filteredLayers.length === 0) {
Expand Down Expand Up @@ -547,6 +546,7 @@ export function XYChart({
}}
baseTheme={chartBaseTheme}
tooltip={{
boundary: document.getElementById('app-fixed-viewport') ?? undefined,
headerFormatter: (d) => safeXAccessorLabelRenderer(d.value),
}}
rotation={shouldRotate ? 90 : 0}
Expand Down