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
Open
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
20 changes: 20 additions & 0 deletions src/table/__integ__/resizable-columns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ class TablePage extends BasePageObject {
});
}

getTableClientWidth() {
return this.browser.execute(() => document.querySelector('table')!.clientWidth);
}

getTableScrollWidth() {
return this.browser.execute(() => document.querySelector('table')!.scrollWidth);
}

async getColumnMinWidth(columnIndex: number) {
const columnSelector = tableWrapper
// use internal CSS-selector to always receive the real table header and not a sticky copy
Expand Down Expand Up @@ -368,3 +376,15 @@ test.each([false, true])(
);
}
);

test.each([false, true])('should not be horizontally scrollable upon rendering, isFullPage=%s', isFullPage =>
useBrowser({ width: 1200, height: 1000 }, async browser => {
const page = new TablePage(browser);
await browser.url(`#/light/table/resizable-columns?visualRefresh=true&fullPage=${String(isFullPage)}`);
await page.waitForVisible(tableWrapper.findBodyCell(2, 1).toSelector());

const tableClientWidth = await page.getTableClientWidth();
const tableScrollWidth = await page.getTableScrollWidth();
expect(tableScrollWidth).toBe(tableClientWidth);
})()
);
3 changes: 2 additions & 1 deletion src/table/header-cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface TableHeaderCellProps<ItemType> {
isExpandable?: boolean;
hasDynamicContent?: boolean;
variant: TableProps.Variant;
tableVariant?: string;
tableVariant?: TableProps.Variant;
}

export function TableHeaderCell<ItemType>({
Expand Down Expand Up @@ -213,6 +213,7 @@ export function TableHeaderCell<ItemType>({
// TODO: Replace with this when strings are available
// tooltipText={i18n('ariaLabels.resizerTooltipText', resizerTooltipText)}
tooltipText={resizerTooltipText}
isBorderless={variant === 'full-page' || variant === 'embedded' || variant === 'borderless'}
/>
) : (
<Divider className={styles['resize-divider']} />
Expand Down
2 changes: 1 addition & 1 deletion src/table/header-cell/th-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export interface TableThElementProps {
tableRole: TableRole;
children: React.ReactNode;
variant: TableProps.Variant;
tableVariant?: TableProps.Variant;
ariaLabel?: string;
tableVariant?: string;
}

export function TableThElement({
Expand Down
14 changes: 12 additions & 2 deletions src/table/resizer/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ describe('Resizer component', () => {
<thead>
<tr>
<th>
<Resizer onWidthUpdate={mockOnWidthUpdate} onWidthUpdateCommit={mockOnWidthUpdateCommit} minWidth={80} />
<Resizer
onWidthUpdate={mockOnWidthUpdate}
onWidthUpdateCommit={mockOnWidthUpdateCommit}
minWidth={80}
isBorderless={false}
/>
</th>
</tr>
</thead>
Expand All @@ -54,7 +59,12 @@ describe('Resizer component', () => {
<thead>
<tr>
<th>
<Resizer onWidthUpdate={mockOnWidthUpdate} onWidthUpdateCommit={mockOnWidthUpdateCommit} minWidth={80} />
<Resizer
onWidthUpdate={mockOnWidthUpdate}
onWidthUpdateCommit={mockOnWidthUpdateCommit}
minWidth={80}
isBorderless={false}
/>
</th>
</tr>
</thead>
Expand Down
15 changes: 7 additions & 8 deletions src/table/resizer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface ResizerProps {
showFocusRing?: boolean;
roleDescription?: string;
tooltipText?: string;
isBorderless: boolean;
}

const AUTO_GROW_START_TIME = 10;
Expand All @@ -47,6 +48,7 @@ export function Resizer({
focusId,
roleDescription,
tooltipText,
isBorderless,
}: ResizerProps) {
onWidthUpdate = useStableCallback(onWidthUpdate);
onWidthUpdateCommit = useStableCallback(onWidthUpdateCommit);
Expand Down Expand Up @@ -319,7 +321,9 @@ export function Resizer({

return (
<div
className={clsx(styles['resizer-wrapper'], isVisualRefresh && styles['is-visual-refresh'])}
// When the table is borderless (works in visual refresh tables only), the last resize handle must not
// exceed table's edges, as it causes an unintended overflow otherwise.
className={clsx(styles['resizer-wrapper'], (!isVisualRefresh || isBorderless) && styles['is-borderless'])}
ref={positioningWrapperRef}
>
<DragHandleWrapper
Expand Down Expand Up @@ -360,8 +364,7 @@ export function Resizer({
ref={resizerToggleRef}
className={clsx(
styles.resizer,
(resizerHasFocus || showFocusRing || isKeyboardDragging) && styles['has-focus'],
isVisualRefresh && styles['is-visual-refresh']
(resizerHasFocus || showFocusRing || isKeyboardDragging) && styles['has-focus']
)}
onPointerDown={event => {
if (event.pointerType === 'mouse' && event.button !== 0) {
Expand Down Expand Up @@ -400,11 +403,7 @@ export function Resizer({
data-focus-id={focusId}
/>
<span
className={clsx(
styles['divider-interactive'],
(isPointerDown || isDragging) && styles['divider-active'],
isVisualRefresh && styles['is-visual-refresh']
)}
className={clsx(styles['divider-interactive'], (isPointerDown || isDragging) && styles['divider-active'])}
data-awsui-table-suppress-navigation={true}
ref={resizerSeparatorRef}
id={separatorId}
Expand Down
13 changes: 7 additions & 6 deletions src/table/resizer/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ $block-gap: calc(2 * #{awsui.$space-xs} + #{awsui.$space-xxxs});
.resizer-wrapper {
inset-block: 0;
position: absolute;
inset-inline-end: calc(-1 * #{$handle-width} / 2);
inset-inline-end: calc(-1 * $handle-width / 2);
inline-size: $handle-width;
overflow: hidden;
z-index: 10;

th:last-child > &:has(.divider-interactive):not(.is-visual-refresh) {
th:last-child > &:has(.divider-interactive).is-borderless {
inset-inline-end: 0;
}
}
Expand Down Expand Up @@ -58,6 +58,11 @@ th:not(:last-child) > .divider-disabled {
inset-inline-end: calc(#{$handle-width} / 2);
}

// stylelint-disable-next-line selector-combinator-disallowed-list
th:last-child > .resizer-wrapper.is-borderless .divider-interactive {
inset-inline-end: 0;
}

.divider-active {
border-inline-start: $active-separator-width solid awsui.$color-border-divider-active;
}
Expand Down Expand Up @@ -89,10 +94,6 @@ th:not(:last-child) > .divider-disabled {
}
}

th:last-child > .resizer:not(.is-visual-refresh) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this was some old rule that never applied (because the descendant of the th is .resize-wrapper, not .resizer.

inset-inline-end: 0;
}

.tracker {
display: none;
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion src/table/thead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface TheadProps {
sortingDescending: boolean | undefined;
sortingDisabled: boolean | undefined;
variant: TableProps.Variant;
tableVariant?: string;
tableVariant?: TableProps.Variant;
wrapLines: boolean | undefined;
resizableColumns: boolean | undefined;
getSelectAllProps?: () => SelectionProps;
Expand Down
Loading