Skip to content

Commit c41e644

Browse files
committed
fix: column resize and pinned column width corruption
- ColumnResizeHandle now uses logical stored width (currentWidth prop) instead of reading DOM getBoundingClientRect, fixing jitter on resize and preventing width corruption when a pinned column is resized - Header passes effectiveWidth (columnWidths[field] ?? colDef.width) to ColumnResizeHandle as the correct baseline for drag calculations - CSS auto-import added to barrel index.ts for all bundler environments
1 parent 4b3da92 commit c41e644

6 files changed

Lines changed: 25 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55

66
---
77

8+
## [0.1.3] — March 10, 2026 🐛
9+
10+
### Fixed
11+
- CSS is now explicitly imported at the barrel entry (`lib/index.ts`) in addition to `DataGrid.tsx`, ensuring styles are never silently dropped by bundlers (Vite, Webpack, Next.js App Router) that don't auto-resolve side-effect CSS from library packages.
12+
13+
### Docs
14+
- Updated `README.md` to accurately describe CSS handling and provide a clear fallback import instruction for all environments.
15+
16+
---
17+
818
## [0.1.2] — March 6, 2026 🐛
919

1020
### Fixed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ npm install @opencorestack/opengridx
1717
```
1818

1919
```tsx
20-
// Styles are automatically included — no separate CSS import needed
2120
import { DataGrid } from '@opencorestack/opengridx';
2221
```
2322

24-
> **Note:** Styles are bundled inside the component. For SSR or CSS-in-JS setups use the explicit styles export:
23+
> **Styles:** The CSS is bundled as a separate file (`opengridx.css`) alongside the JS. It is imported automatically via the package barrel in most setups.
24+
> However, **if your grid appears unstyled** (Vite, Next.js App Router, or SSR environments sometimes skip side-effect CSS auto-detection), add this explicit import once — typically in your app's root file (`main.tsx` / `layout.tsx`):
25+
>
2526
> ```tsx
2627
> import '@opencorestack/opengridx/styles';
2728
> ```
2829
2930
---
3031
32+
3133
## ⚡ Basic Example
3234
3335
```tsx

lib/components/ColumnResizeHandle/ColumnResizeHandle.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import React, { useCallback, useRef, useState } from 'react';
44

55
export interface ColumnResizeHandleProps {
66
field: string;
7+
currentWidth: number;
78
onResize: (field: string, newWidth: number) => void;
89
minWidth?: number;
910
maxWidth?: number;
1011
}
1112

1213
export function ColumnResizeHandle(props: ColumnResizeHandleProps) {
13-
const { field, onResize, minWidth = 50, maxWidth = 1000 } = props;
14+
const { field, currentWidth, onResize, minWidth = 50, maxWidth = 1000 } = props;
1415
const [isDragging, setIsDragging] = useState(false);
1516
const startXRef = useRef<number>(0);
1617
const startWidthRef = useRef<number>(0);
@@ -21,11 +22,8 @@ export function ColumnResizeHandle(props: ColumnResizeHandleProps) {
2122

2223
setIsDragging(true);
2324
startXRef.current = event.clientX;
24-
25-
const headerCell = (event.target as HTMLElement).closest('.ogx__header-cell');
26-
if (headerCell) {
27-
startWidthRef.current = headerCell.getBoundingClientRect().width;
28-
}
25+
// Use the logical stored width — reliable for pinned, flex, and normal columns
26+
startWidthRef.current = currentWidth;
2927

3028
let lastUpdateTime = 0;
3129
const throttleMs = 16;
@@ -55,14 +53,12 @@ export function ColumnResizeHandle(props: ColumnResizeHandleProps) {
5553

5654
document.addEventListener('mousemove', handleMouseMove);
5755
document.addEventListener('mouseup', handleMouseUp);
58-
}, [field, onResize, minWidth, maxWidth]);
56+
}, [field, currentWidth, onResize, minWidth, maxWidth]);
5957

6058
const handleDoubleClick = useCallback((event: React.MouseEvent) => {
6159
event.preventDefault();
6260
event.stopPropagation();
63-
64-
65-
}, [field]);
61+
}, []);
6662

6763
const classNames = [
6864
'ogx-column-resize-handle',

lib/components/Header/Header.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ export function Header<R extends GridRowModel = GridRowModel>(props: HeaderProps
487487
{isResizable && onColumnResize && (
488488
<ColumnResizeHandle
489489
field={colDef.field}
490+
currentWidth={effectiveWidth}
490491
onResize={onColumnResize}
491492
minWidth={colDef.minWidth}
492493
maxWidth={colDef.maxWidth}

lib/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
// Auto-import styles — this ensures consumers do NOT need a manual CSS import
3+
import './styles/opengridx.css';
4+
25
export { DataGrid } from './components/DataGrid/DataGrid';
36
export { Cell } from './components/Cell/Cell';
47
export { Row } from './components/Row/Row';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencorestack/opengridx",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "OpenGridX: High-performance React data infrastructure. Unlock advanced Row Grouping, Excel Export, and Column Pinning without the usual \"Pro\" gatekeeping. Built for speed, scale, and complete architectural freedom. Fully open, virtualization-ready, and feature-complete.",
55
"type": "module",
66
"main": "./dist/opengridx.umd.js",

0 commit comments

Comments
 (0)