Skip to content
Merged
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
24 changes: 24 additions & 0 deletions apps/playground-e2e/src/playground.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,30 @@ test.describe('reordering columns', () => {
});
});

// Widening a column slides its grip under the pointer, and Chrome then
// started dragging the grip instead, which stopped the resize.
test('resizes a movable column without moving it', async ({ page }) => {
const separator = demo(page, sorting).getByRole('separator', {
name: 'Resize Status',
});
const box = await separator.boundingBox();
const x = (box?.x ?? 0) + (box?.width ?? 0) / 2;
const y = (box?.y ?? 0) + (box?.height ?? 0) / 2;

await page.mouse.move(x, y);
await page.mouse.down();
await page.mouse.move(x + 60, y, { steps: 6 });
await page.mouse.up();

await expect(separator).toHaveAttribute('aria-valuenow', '210');
expect(await headers(page, sorting)).toEqual([
'Title',
'Status',
'Owner',
'Due',
]);
});

test('gives the handle a target of at least 24 pixels', async ({ page }) => {
const header = demo(page, sorting).getByRole('columnheader', {
name: /Owner/,
Expand Down
15 changes: 15 additions & 0 deletions packages/sheets/src/ui/sheet-column-move.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ describe('moving columns', () => {
expect(headers()).toEqual(['G', 'C', 'A', 'B']);
});

it('starts no drag while a column is resized', () => {
render(<Grid />);
fireEvent.mouseDown(screen.getByRole('separator', { name: 'Resize A' }), {
clientX: 100,
});

const started = fireEvent.dragStart(
screen.getByRole('button', { name: 'Move A' }),
{ dataTransfer: transfer() },
);

expect(started).toBe(false);
fireEvent.mouseUp(document, { clientX: 100 });
});

it('refuses a column dragged from another sheet', () => {
render(
<>
Expand Down
7 changes: 7 additions & 0 deletions packages/sheets/src/ui/sheet-column-move.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export function SheetColumnMove<TData extends RowData>({
aria-label={name}
style={{ anchorName: anchor }}
onDragStart={(event) => {
// Widening a column slides this grip under the point where its
// resize began, and Chrome and Safari then start dragging the grip,
// which stops the resize. No column moves while one is resized.
if (table.atoms.columnResizing.get().isResizingColumn) {
event.preventDefault();
return;
}
dragged.current = column.id;
if (open) panel.current?.hidePopover();
event.dataTransfer.effectAllowed = 'move';
Expand Down