From 8ed07a7027566beacc5539805a4ff844070cc5d2 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 19 Feb 2019 17:14:21 +0100 Subject: [PATCH] Fix legend / color picker overflow (#30960) --- .../vis/vis_types/_vislib_vis_legend.scss | 71 ++++++++++++++----- .../vis/vis_types/vislib_vis_legend.html | 8 +-- .../public/vis/vis_types/vislib_vis_legend.js | 14 +++- 3 files changed, 69 insertions(+), 24 deletions(-) diff --git a/src/legacy/ui/public/vis/vis_types/_vislib_vis_legend.scss b/src/legacy/ui/public/vis/vis_types/_vislib_vis_legend.scss index 532b489d7bc755b..35193303360acaa 100644 --- a/src/legacy/ui/public/vis/vis_types/_vislib_vis_legend.scss +++ b/src/legacy/ui/public/vis/vis_types/_vislib_vis_legend.scss @@ -2,6 +2,10 @@ // NOTE: Some of the styles attempt to align with the TSVB legend +$visLegendWidth: 150px; +$visColorPickerWidth: $euiSizeM * 10; +$visLegendLineHeight: $euiSize; + .visLegend__toggle { border-radius: $euiBorderRadius; position: absolute; @@ -28,10 +32,9 @@ display: flex; min-height: 0; height: 100%; - overflow: hidden; } -.visLib--legend-left{ +.visLib--legend-left { .visLegend__list { margin-bottom: $euiSizeL; } @@ -43,21 +46,31 @@ } } +/** + * 1. Position the .visLegend__valueDetails absolutely against the legend item + * 2. Make sure the .visLegend__valueDetails is visible outside the list bounds + * 3. Make sure the currently selected item is top most in z level + */ .visLegend__list { @include euiScrollBar; - line-height: $euiSize; - width: 150px; // Must be a hard-coded width for the chart to get its correct dimensions + display: flex; + line-height: $visLegendLineHeight; + width: $visLegendWidth; // Must be a hard-coded width for the chart to get its correct dimensions flex: 1 1 auto; + flex-direction: column; overflow-x: hidden; overflow-y: auto; .visLib--legend-top &, .visLib--legend-bottom & { width: auto; - overflow-y: hidden; + flex-direction: row; + flex-wrap: wrap; + overflow: visible; /* 2 */ .visLegend__value { - display: inline-block; + flex-grow: 0; + max-width: $visLegendWidth; } } @@ -70,9 +83,11 @@ cursor: pointer; padding: $euiSizeXS; display: flex; + flex-shrink: 0; + position: relative; /* 1 */ > * { - max-width: 100%; + max-width: 100%; // Needed for truncation (dom element has no class) } &.disabled { @@ -81,6 +96,7 @@ } .visLegend__valueTitle { + @include euiTextTruncate; // ALWAYS truncate color: $visTextColor; &:hover { @@ -88,25 +104,46 @@ } } -.visLegend__valueTitle--truncate { - @include euiTextTruncate; -} - -.visLegend__valueTitle--full { - word-break: break-all; +.visLegend__valueTitle--full ~ .visLegend__valueDetails { + z-index: 2; /* 3 */ } .visLegend__valueDetails { - border-bottom: 1px solid $euiColorLightShade; - padding-bottom: $euiSizeXS; + background-color: $euiColorEmptyShade; + + .visLib--legend-left &, + .visLib--legend-right & { + margin-top: $euiSizeXS; + border-bottom: $euiBorderThin; + } + + .visLib--legend-top &, + .visLib--legend-bottom & { + @include euiBottomShadowMedium; + position: absolute; /* 1 */ + border-radius: $euiBorderRadius; + } + + .visLib--legend-bottom & { + bottom: $visLegendLineHeight + 2 * $euiSizeXS; + } + + .visLib--legend-top & { + margin-top: $euiSizeXS; + } } .visLegend__valueColorPicker { - width: $euiSizeM * 10; + width: $visColorPickerWidth; margin: auto; .visLegend__valueColorPickerDot { - margin: $euiSizeXS / 2; + $colorPickerDotsPerRow: 8; + $colorPickerDotMargin: $euiSizeXS / 2; + $colorPickerDotWidth: $visColorPickerWidth / $colorPickerDotsPerRow - 2 * $colorPickerDotMargin; + + margin: $colorPickerDotMargin; + width: $colorPickerDotWidth; &:hover { transform: scale(1.4); diff --git a/src/legacy/ui/public/vis/vis_types/vislib_vis_legend.html b/src/legacy/ui/public/vis/vis_types/vislib_vis_legend.html index 52fb7e43471fe50..70d2a796658f2f5 100644 --- a/src/legacy/ui/public/vis/vis_types/vislib_vis_legend.html +++ b/src/legacy/ui/public/vis/vis_types/vislib_vis_legend.html @@ -22,14 +22,14 @@ class="visLegend__value color" > -
+
-
+