WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 7ea5fd8

Browse files
committed
fix: Fixes table resizer overflow causing unwanted scroll
1 parent 81f493f commit 7ea5fd8

File tree

6 files changed

+38
-17
lines changed

6 files changed

+38
-17
lines changed

src/table/__integ__/resizable-columns.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ class TablePage extends BasePageObject {
7676
});
7777
}
7878

79+
getTableClientWidth() {
80+
return this.browser.execute(() => document.querySelector('table')!.clientWidth);
81+
}
82+
83+
getTableScrollWidth() {
84+
return this.browser.execute(() => document.querySelector('table')!.scrollWidth);
85+
}
86+
7987
async getColumnMinWidth(columnIndex: number) {
8088
const columnSelector = tableWrapper
8189
// use internal CSS-selector to always receive the real table header and not a sticky copy
@@ -368,3 +376,15 @@ test.each([false, true])(
368376
);
369377
}
370378
);
379+
380+
test.each([false, true])('should not be horizontally scrollable upon rendering, isFullPage=%s', isFullPage =>
381+
useBrowser({ width: 1200, height: 1000 }, async browser => {
382+
const page = new TablePage(browser);
383+
await browser.url(`#/light/table/resizable-columns?visualRefresh=true&fullPage=${String(isFullPage)}`);
384+
await page.waitForVisible(tableWrapper.findBodyCell(2, 1).toSelector());
385+
386+
const tableClientWidth = await page.getTableClientWidth();
387+
const tableScrollWidth = await page.getTableScrollWidth();
388+
expect(tableScrollWidth).toBe(tableClientWidth);
389+
})()
390+
);

src/table/header-cell/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface TableHeaderCellProps<ItemType> {
5050
isExpandable?: boolean;
5151
hasDynamicContent?: boolean;
5252
variant: TableProps.Variant;
53-
tableVariant?: string;
53+
tableVariant?: TableProps.Variant;
5454
}
5555

5656
export function TableHeaderCell<ItemType>({
@@ -213,6 +213,7 @@ export function TableHeaderCell<ItemType>({
213213
// TODO: Replace with this when strings are available
214214
// tooltipText={i18n('ariaLabels.resizerTooltipText', resizerTooltipText)}
215215
tooltipText={resizerTooltipText}
216+
isBorderless={variant === 'full-page' || variant === 'embedded' || variant === 'borderless'}
216217
/>
217218
) : (
218219
<Divider className={styles['resize-divider']} />

src/table/header-cell/th-element.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export interface TableThElementProps {
3636
tableRole: TableRole;
3737
children: React.ReactNode;
3838
variant: TableProps.Variant;
39+
tableVariant?: TableProps.Variant;
3940
ariaLabel?: string;
40-
tableVariant?: string;
4141
}
4242

4343
export function TableThElement({

src/table/resizer/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface ResizerProps {
2727
showFocusRing?: boolean;
2828
roleDescription?: string;
2929
tooltipText?: string;
30+
isBorderless: boolean;
3031
}
3132

3233
const AUTO_GROW_START_TIME = 10;
@@ -47,6 +48,7 @@ export function Resizer({
4748
focusId,
4849
roleDescription,
4950
tooltipText,
51+
isBorderless,
5052
}: ResizerProps) {
5153
onWidthUpdate = useStableCallback(onWidthUpdate);
5254
onWidthUpdateCommit = useStableCallback(onWidthUpdateCommit);
@@ -319,7 +321,9 @@ export function Resizer({
319321

320322
return (
321323
<div
322-
className={clsx(styles['resizer-wrapper'], isVisualRefresh && styles['is-visual-refresh'])}
324+
// When the table is borderless (works in visual refresh tables only), the last resize handle must not
325+
// exceed table's edges, as it causes an unintended overflow otherwise.
326+
className={clsx(styles['resizer-wrapper'], (!isVisualRefresh || isBorderless) && styles['is-borderless'])}
323327
ref={positioningWrapperRef}
324328
>
325329
<DragHandleWrapper
@@ -360,8 +364,7 @@ export function Resizer({
360364
ref={resizerToggleRef}
361365
className={clsx(
362366
styles.resizer,
363-
(resizerHasFocus || showFocusRing || isKeyboardDragging) && styles['has-focus'],
364-
isVisualRefresh && styles['is-visual-refresh']
367+
(resizerHasFocus || showFocusRing || isKeyboardDragging) && styles['has-focus']
365368
)}
366369
onPointerDown={event => {
367370
if (event.pointerType === 'mouse' && event.button !== 0) {
@@ -400,11 +403,7 @@ export function Resizer({
400403
data-focus-id={focusId}
401404
/>
402405
<span
403-
className={clsx(
404-
styles['divider-interactive'],
405-
(isPointerDown || isDragging) && styles['divider-active'],
406-
isVisualRefresh && styles['is-visual-refresh']
407-
)}
406+
className={clsx(styles['divider-interactive'], (isPointerDown || isDragging) && styles['divider-active'])}
408407
data-awsui-table-suppress-navigation={true}
409408
ref={resizerSeparatorRef}
410409
id={separatorId}

src/table/resizer/styles.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ $block-gap: calc(2 * #{awsui.$space-xs} + #{awsui.$space-xxxs});
2020
.resizer-wrapper {
2121
inset-block: 0;
2222
position: absolute;
23-
inset-inline-end: calc(-1 * #{$handle-width} / 2);
23+
inset-inline-end: calc(-1 * $handle-width / 2);
2424
inline-size: $handle-width;
2525
overflow: hidden;
2626
z-index: 10;
2727

28-
th:last-child > &:has(.divider-interactive):not(.is-visual-refresh) {
28+
th:last-child > &:has(.divider-interactive).is-borderless {
2929
inset-inline-end: 0;
3030
}
3131
}
@@ -58,6 +58,11 @@ th:not(:last-child) > .divider-disabled {
5858
inset-inline-end: calc(#{$handle-width} / 2);
5959
}
6060

61+
// stylelint-disable-next-line selector-combinator-disallowed-list
62+
th:last-child > .resizer-wrapper.is-borderless .divider-interactive {
63+
inset-inline-end: 0;
64+
}
65+
6166
.divider-active {
6267
border-inline-start: $active-separator-width solid awsui.$color-border-divider-active;
6368
}
@@ -89,10 +94,6 @@ th:not(:last-child) > .divider-disabled {
8994
}
9095
}
9196

92-
th:last-child > .resizer:not(.is-visual-refresh) {
93-
inset-inline-end: 0;
94-
}
95-
9697
.tracker {
9798
display: none;
9899
position: absolute;

src/table/thead.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface TheadProps {
2424
sortingDescending: boolean | undefined;
2525
sortingDisabled: boolean | undefined;
2626
variant: TableProps.Variant;
27-
tableVariant?: string;
27+
tableVariant?: TableProps.Variant;
2828
wrapLines: boolean | undefined;
2929
resizableColumns: boolean | undefined;
3030
getSelectAllProps?: () => SelectionProps;

0 commit comments

Comments
 (0)