Skip to content

Commit f65562c

Browse files
committed
Merge branch 'fix/resizer-deferred' into fix/at-scale-width-perf
2 parents 76e1e7c + df3d61d commit f65562c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/main/src/components/AnalyticalTable/hooks/useColumnResizing.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function getProjectedWidth(rawDeltaX: number, originalWidth: number, isRt
4040
* - Split mouse/touch into separate branches (touch needs `{ passive: false }` for `preventDefault()`)
4141
* - Added 3px dead zone and `data-active-resizer` attribute for double-click compatibility
4242
* - Removed `cursor: col-resize` style (AnalyticalTable provides its own resizer styling)
43-
* - Clamped resize width to `minWidth` in both the visual drag and the reducer (original clamps to 0)
43+
* - Clamped resize width to `minWidth`/`maxWidth` in both the visual drag and the reducer (original clamps to 0)
4444
* - Fixed falsy `0` bug: replaced `||` with `??` in `useInstanceBeforeDimensions` width assignment
4545
*/
4646
export const useColumnResizing = (hooks: ReactTableHooks) => {
@@ -59,9 +59,10 @@ const deferredGetResizerProps: ReactTableHooks['getResizerProps'][0] = (props, {
5959

6060
const startResize = (resizerElement: HTMLDivElement, startClientX: number, isTouchEvent: boolean) => {
6161
// UI5WCR: use header directly instead of getLeafHeaders (no grouped columns)
62-
const headerIdWidths = [[header.id, header.totalWidth, header.minWidth]];
62+
const headerIdWidths = [[header.id, header.totalWidth, header.minWidth, header.maxWidth]];
6363
const columnWidth = header.totalWidth;
6464
const minWidth = header.minWidth;
65+
const maxWidth = header.maxWidth;
6566
const columnId = header.id;
6667
const isRtl = instance.state.isRtl;
6768

@@ -96,11 +97,13 @@ const deferredGetResizerProps: ReactTableHooks['getResizerProps'][0] = (props, {
9697
// UI5WCR: 3px dead zone prevents transform shifts during double-click sequences
9798
const applyDrag = (clientX: number) => {
9899
deltaX = clientX - startClientX;
99-
// UI5WCR: clamp so resizer can't be dragged past minWidth boundary
100+
// UI5WCR: clamp so resizer can't be dragged past minWidth/maxWidth boundary
100101
if (isRtl) {
102+
deltaX = Math.max(deltaX, columnWidth - maxWidth);
101103
deltaX = Math.min(deltaX, columnWidth - minWidth);
102104
} else {
103105
deltaX = Math.max(deltaX, minWidth - columnWidth);
106+
deltaX = Math.min(deltaX, maxWidth - columnWidth);
104107
}
105108
if (!isDragging && Math.abs(deltaX) < 3) {
106109
return;
@@ -207,11 +210,13 @@ const reducer: TableInstance['stateReducer'] = (state, action) => {
207210

208211
const newColumnWidths: Record<string, number> = {};
209212

210-
headerIdWidths.forEach(([headerId, headerWidth, headerMinWidth]: [string, number, number]) => {
211-
// UI5WCR: clamp to minWidth (original only clamps to 0)
212-
const projected = getProjectedWidth(rawDeltaX, headerWidth, state.isRtl);
213-
newColumnWidths[headerId] = Math.max(projected, headerMinWidth);
214-
});
213+
headerIdWidths.forEach(
214+
([headerId, headerWidth, headerMinWidth, headerMaxWidth]: [string, number, number, number]) => {
215+
// UI5WCR: clamp to minWidth/maxWidth (original only clamps to 0)
216+
const projected = getProjectedWidth(rawDeltaX, headerWidth, state.isRtl);
217+
newColumnWidths[headerId] = Math.min(Math.max(projected, headerMinWidth), headerMaxWidth);
218+
},
219+
);
215220

216221
return {
217222
...state,

0 commit comments

Comments
 (0)