Skip to content

Commit b2c8762

Browse files
authored
[Dashboard] do not change the geometry of hover actions on drag (#216412)
## Summary While working on [PR #208286](#208286), I found a small but noticeable bug: When using keyboard navigation with compacted hover actions, the element shifts slightly left when moving up/down. https://github.com/user-attachments/assets/71e44671-c98a-4e09-a0a0-1c79efeefa25 #### Cause: * `sensorOffsets` are calculated before activation, when the panel has a 1px border. * Activating the element increases the border to 2px, throwing off the position calculation. #### Why we cannot use outline (that is used for panels to avoid shifting the layout): For panels, this problem is avoided by using outline, but here we can't because `outline` applies uniformly to all sides. Here, we need to avoid displaying a bottom border. #### Before fix (Notice how hover actions get slightly wider) https://github.com/user-attachments/assets/a6b8dd02-4be2-4425-bf28-2af6dde3b023 https://github.com/user-attachments/assets/03c5aa71-cd3c-4181-bb4c-05a2003775f5 After Fix: The dimensions of the whole active panel and actions are stable: https://github.com/user-attachments/assets/d7ba766e-2567-4c3e-a2d6-9c95de2e2f9a https://github.com/user-attachments/assets/220ee96f-29b8-4f68-bd9c-1d2ee15b9e5d I know this makes the implementation slightly more complex, but I couldn't find a simpler solution that covers all cases (dotted line forces us to us `outline` or `border` for panel, but no bottom border forces us to use `border` (which causes this problem) or `box-shadow`)
1 parent bbaa054 commit b2c8762

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Diff for: src/platform/plugins/private/presentation_panel/public/panel_component/panel_header/use_hover_actions_styles.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,18 @@ export const useHoverActionStyles = (isEditMode: boolean, showBorder?: boolean)
9898
9999
border-radius: ${euiTheme.border.radius.medium};
100100
border: var(--internalBorderStyle);
101+
border-width: ${euiTheme.border.width
102+
.thin}; /* Prevents the element from resizing when dragged by keeping the border width constant (overriding the default change from 1px to 2px) */
103+
box-shadow: var(
104+
--hoverActionsSingleWrapperBoxShadowStyle
105+
); /* Simulates a 2px border without affecting layout by using a box-shadow */
101106
background-color: ${euiTheme.colors.backgroundBasePlain};
102107
grid-template-columns: max-content;
103108
104109
& > * {
105110
// undo certain styles on all children so that parent takes precedence
106111
border: none !important;
112+
box-shadow: none !important;
107113
padding: 0px !important;
108114
border-radius: unset !important;
109115
background-color: transparent !important;
@@ -131,6 +137,11 @@ export const useHoverActionStyles = (isEditMode: boolean, showBorder?: boolean)
131137
pointer-events: all; // re-enable pointer events for non-breakpoint children
132138
background-color: ${euiTheme.colors.backgroundBasePlain};
133139
border: var(--internalBorderStyle);
140+
border-width: ${euiTheme.border.width
141+
.thin}; /* Prevents the element from resizing when dragged by keeping the border width constant (overriding the default change from 1px to 2px) */
142+
box-shadow: var(
143+
--hoverActionsBoxShadowStyle
144+
); /* Simulates a 2px 3-side border without affecting layout by using a box-shadow */
134145
border-bottom: 0px;
135146
padding: var(--paddingAroundAction);
136147
padding-bottom: 0px;

Diff for: src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/use_layout_styles.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export const useLayoutStyles = () => {
3333
--dashboardActivePanelBorderStyle: ${euiTheme.border.width.thick} solid
3434
${euiTheme.colors.vis.euiColorVis0};
3535
36+
--dashboardHoverActionsActivePanelBoxShadow--singleWrapper: 0 0 0
37+
${euiTheme.border.width.thin} ${euiTheme.colors.vis.euiColorVis0};
38+
39+
--dashboardHoverActionsActivePanelBoxShadow: -${euiTheme.border.width.thin} 0 ${euiTheme.colors.vis.euiColorVis0},
40+
${euiTheme.border.width.thin} 0 ${euiTheme.colors.vis.euiColorVis0},
41+
0 -${euiTheme.border.width.thin} ${euiTheme.colors.vis.euiColorVis0};
42+
3643
&.kbnGrid {
3744
// remove margin top + bottom on grid in favour of padding in row
3845
padding-bottom: 0px;
@@ -84,6 +91,10 @@ export const useLayoutStyles = () => {
8491
.kbnGridPanel--active {
8592
// overwrite the border style on panels + hover actions for active panels
8693
--hoverActionsBorderStyle: var(--dashboardActivePanelBorderStyle);
94+
--hoverActionsBoxShadowStyle: var(--dashboardHoverActionsActivePanelBoxShadow);
95+
--hoverActionsSingleWrapperBoxShadowStyle: var(
96+
--dashboardHoverActionsActivePanelBoxShadow--singleWrapper
97+
);
8798
8899
// prevent the hover actions transition when active to prevent "blip" on resize
89100
.embPanel__hoverActions {

0 commit comments

Comments
 (0)