Skip to content

Commit 6a5ddba

Browse files
committed
fix(resize): release pointer capture when a resize ends; test: release drags over the page so WebKit does not keep the button pressed
1 parent 282f55a commit 6a5ddba

5 files changed

Lines changed: 22 additions & 11 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
### Fixed
1515

16+
- The column resize handle now releases its pointer capture when a resize ends. A capture left behind (for example by a press that never got a real `pointerup`) could keep the pointer's later events from reaching the rest of the page.
1617
- **Apps without the optional export peers failed to build in webpack and Next.js** (`Module not found: Can't resolve 'exceljs'` from `next build` on Next.js 15 and 16, and from plain webpack 5). The `exceljs` import in `exportToExcelAdvanced` now sits inside a `try` block, as the `jspdf` imports already did, which webpack and Turbopack treat as an optional dependency: apps without `exceljs`, `jspdf` and `jspdf-autotable` build (webpack shows a warning) and `exportToExcelAdvanced` rejects with `exportToExcelAdvanced requires 'exceljs'. Run: npm install exceljs`. Apps that install the peers are unchanged. The `next.config.ts` aliases in the Next.js guide are no longer needed. The package smoke suite has a third fixture, `e2e/fixtures/nopeers` (webpack 5, no peers), that must build, render the grid and get the install hints in Chromium, Firefox and WebKit.
1718
- **`validateGridAiState` reported a top-level `message` as "Unknown part"** when given a JSON string, and also for an object passed directly. A string `message` (the model's reply text) is now skipped in both forms; a non-string `message` is reported as `Expected text, got …`. `createGridAiPromptHandler` now also returns a `message` key found inside a JSON string reply or a fenced JSON block as `result.message` (joined with the text around the block when both exist), as it did for object replies. The Next.js guide no longer strips `message` before validating.
1819
- **Importing the grid from a React Server Component crashed the build** (`TypeError: createContext is not a function` in Next.js App Router "collecting page data"). `dist/opengridx.es.js` now starts with `'use client'`, so a Server Component gets a client reference: `<DataGrid>` with serialisable props can be rendered from a server file, and the grid hydrates in the browser. Wrapping it in your own `'use client'` file (needed for column functions) works as before. `scripts/check-bundle.mjs` checks the directive. The UMD build is minified and does not carry it; Next.js and other RSC bundlers load the ES build.

‎docs/roadmap.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ This document tracks the current status of features in `OpenGridX` and outlines
117117

118118
## 🔭 Next (Q1 2027)
119119

120-
* **Fill handle: also start from `mousedown`.** Playwright's WebKit sometimes delivers a press on the handle without a `pointerdown` (seen after the RTL suite, 2026-10-12); the auto-scroll fill test is skipped in WebKit until the handle starts a fill from either event.
121120

122121
* **Row reordering inside tree data and row groups**, touch-friendly (MUI #4821, 405 👍, not in MUI X).
123122
* **Find & highlight** (Ctrl+F through cells), **right-click context menu**, **Excel-style value (set) filter**.

‎lib/components/ColumnResizeHandle/ColumnResizeHandle.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ export function ColumnResizeHandle(props: ColumnResizeHandleProps) {
102102
if (!active || event.pointerId !== active.pointerId) return;
103103
activeRef.current = null;
104104
setIsDragging(false);
105+
// Release explicitly: the implicit release only follows a real pointerup, and a capture left on
106+
// this handle (a synthetic press on the live mouse pointer, or an interrupted drag) would keep
107+
// the pointer's later events from reaching the rest of the page.
108+
if (event.currentTarget.hasPointerCapture?.(event.pointerId)) {
109+
try {
110+
event.currentTarget.releasePointerCapture(event.pointerId);
111+
} catch {
112+
// Already released.
113+
}
114+
}
105115
if (active.moved || event.clientX !== active.startX) {
106116
// The drag may end over the header cell, which would take the synthesized click as a sort.
107117
suppressNextClick();

‎lib/components/DataGrid/DataGrid.fill.browser.test.tsx‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect, afterEach, beforeEach } from 'vitest';
22
import { render, cleanup } from '@testing-library/react';
3-
import { userEvent, commands, page, server } from 'vitest/browser';
3+
import { userEvent, commands, page } from 'vitest/browser';
44
import { useLayoutEffect, useState } from 'react';
55
import type { ReactNode } from 'react';
66
import '../../styles/opengridx.css';
@@ -107,11 +107,7 @@ async function select(api: () => GridApi, a: [number, string], h: [number, strin
107107
}
108108

109109
describe('fill handle: pointer drag', () => {
110-
// Skipped in WebKit: after the RTL suite has run in the same session, Playwright's WebKit
111-
// intermittently delivers the mouse press without a pointerdown reaching the handle's listener,
112-
// so a range drag starts instead of a fill (seen in about 1 run in 3, logged 2026-10-12). Real
113-
// Safari sends pointerdown; the other fill-drag tests below still cover WebKit.
114-
it.skipIf(server.browser === 'webkit')('drags down past the grid, auto-scrolls and continues the series to the row under the pointer', async () => {
110+
it('drags down past the grid, auto-scrolls and continues the series to the row under the pointer', async () => {
115111
const rows = makeRows(400);
116112
rows[0].c1 = 1;
117113
rows[1].c1 = 2;

‎lib/components/DataGrid/DataGrid.rtl.browser.test.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const ROWS: Row[] = Array.from({ length: 40 }, (_, r) => {
2121
const frame = () => new Promise<void>(r => requestAnimationFrame(() => requestAnimationFrame(() => r())));
2222
const settle = async () => { for (let i = 0; i < 3; i++) await frame(); };
2323

24-
afterEach(() => {
24+
afterEach(async () => {
25+
// Never leave the mouse button pressed for the next test (or test file).
26+
await commands.pointerUp().catch(() => {});
2527
cleanup();
2628
document.documentElement.removeAttribute('dir');
2729
});
@@ -111,9 +113,9 @@ describe('RTL — layout', () => {
111113
const start = box(handle);
112114
const x = start.left + start.width / 2;
113115
const y = start.top + start.height / 2;
114-
fireEvent.pointerDown(handle, { pointerId: 1, button: 0, clientX: x, clientY: y });
115-
fireEvent.pointerMove(handle, { pointerId: 1, clientX: x - 40, clientY: y });
116-
fireEvent.pointerUp(handle, { pointerId: 1, clientX: x - 40, clientY: y });
116+
fireEvent.pointerDown(handle, { pointerId: 91, button: 0, clientX: x, clientY: y });
117+
fireEvent.pointerMove(handle, { pointerId: 91, clientX: x - 40, clientY: y });
118+
fireEvent.pointerUp(handle, { pointerId: 91, clientX: x - 40, clientY: y });
117119
await settle();
118120
expect(Math.round(box(header(container, 'c1')!).width)).toBe(160);
119121
});
@@ -159,6 +161,9 @@ describe('RTL — cell range drag', () => {
159161
const boxTop = container.querySelector<HTMLElement>('[data-testid="box"]')!.getBoundingClientRect().top;
160162
await commands.pointerMoveTo('[data-testid="box"]', -100, row.top - boxTop + row.height / 2);
161163
await expect.poll(() => vp.scrollLeft, { timeout: 8000 }).toBeLessThan(-1000);
164+
// Release over the grid: a release outside the page is lost in WebKit, which then keeps the button
165+
// pressed and swallows the next test file's pointerdown.
166+
await commands.pointerMoveTo('[data-testid="box"]', 100, row.top - boxTop + row.height / 2);
162167
await commands.pointerUp();
163168
await settle();
164169
const inRange = Array.from(container.querySelectorAll<HTMLElement>('.ogx__cell--range')).map(el => Number(el.dataset.field!.slice(1)));

0 commit comments

Comments
 (0)