From 9daaa82ee0b96304aa280b827bcd4c2cf2dd8a14 Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Thu, 12 Sep 2024 15:43:13 -0700 Subject: [PATCH 1/4] Add new `accountForScrollbars` prop --- .../resizable_button.styles.ts | 17 +++++++++++++++-- .../resizable_container/resizable_button.tsx | 10 ++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/eui/src/components/resizable_container/resizable_button.styles.ts b/packages/eui/src/components/resizable_container/resizable_button.styles.ts index a7436cc7554..17d172ef233 100644 --- a/packages/eui/src/components/resizable_container/resizable_button.styles.ts +++ b/packages/eui/src/components/resizable_container/resizable_button.styles.ts @@ -15,6 +15,7 @@ export const euiResizableButtonStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; const buttonSize = euiTheme.size.base; + const negativeMargin = mathWithUnits(buttonSize, (x) => x / -2); const grabHandleWidth = euiTheme.size.m; const grabHandleHeight = euiTheme.border.width.thin; @@ -77,15 +78,27 @@ export const euiResizableButtonStyles = (euiThemeContext: UseEuiTheme) => { cursor: col-resize; ${logicalCSS('height', '100%')} ${logicalCSS('width', buttonSize)} - margin-inline: ${mathWithUnits(buttonSize, (x) => x / -2)}; `, vertical: css` flex-direction: column; cursor: row-resize; ${logicalCSS('width', '100%')} ${logicalCSS('height', buttonSize)} - margin-block: ${mathWithUnits(buttonSize, (x) => x / -2)}; `, + accountForScrollbars: { + horizontal: { + both: css``, + before: css(logicalCSS('margin-right', negativeMargin)), + after: css(logicalCSS('margin-left', negativeMargin)), + none: css(logicalCSS('margin-horizontal', negativeMargin)), + }, + vertical: { + both: css``, + before: css(logicalCSS('margin-bottom', negativeMargin)), + after: css(logicalCSS('margin-top', negativeMargin)), + none: css(logicalCSS('margin-vertical', negativeMargin)), + }, + }, border: css` &::before, diff --git a/packages/eui/src/components/resizable_container/resizable_button.tsx b/packages/eui/src/components/resizable_container/resizable_button.tsx index 11cdb0df2c0..b31bed58a13 100644 --- a/packages/eui/src/components/resizable_container/resizable_button.tsx +++ b/packages/eui/src/components/resizable_container/resizable_button.tsx @@ -47,6 +47,12 @@ export type EuiResizableButtonProps = ButtonHTMLAttributes & * tall content that scrolls off-screen */ alignIndicator?: 'center' | 'start' | 'end'; + /** + * By default, EuiResizableButton will overlap into the panels before/after it. + * This can occasionally occlude interactive elements like scrollbars. To prevent + * this overlap, use this prop to remove the overlap for the specified side. + */ + accountForScrollbars?: 'before' | 'after' | 'both'; /** * When disabled, the resizer button will be completely hidden */ @@ -66,6 +72,7 @@ export const EuiResizableButton = forwardRef< isHorizontal, indicator = 'handle', alignIndicator = 'center', + accountForScrollbars, className, ...rest }, @@ -82,6 +89,9 @@ export const EuiResizableButton = forwardRef< styles[`${indicator}Direction`][resizeDirection], styles[resizeDirection], indicator === 'handle' && styles.alignIndicator[alignIndicator], + styles.accountForScrollbars[resizeDirection][ + accountForScrollbars ?? 'none' + ], ]; return ( From 74d7cee271079913657867146ddbed39f993c4d1 Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Thu, 12 Sep 2024 15:51:06 -0700 Subject: [PATCH 2/4] Update snapshots + stories --- .../resizable_button.test.tsx.snap | 4 ++-- .../resizable_container.test.tsx.snap | 18 +++++++++--------- .../resizable_button.stories.tsx | 5 +++++ .../resizable_container.stories.tsx | 14 +++++++------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/packages/eui/src/components/resizable_container/__snapshots__/resizable_button.test.tsx.snap b/packages/eui/src/components/resizable_container/__snapshots__/resizable_button.test.tsx.snap index a6747ad44f6..0e1ee7cd51f 100644 --- a/packages/eui/src/components/resizable_container/__snapshots__/resizable_button.test.tsx.snap +++ b/packages/eui/src/components/resizable_container/__snapshots__/resizable_button.test.tsx.snap @@ -4,7 +4,7 @@ exports[`EuiResizableButton renders 1`] = `