Skip to content

Commit 32f9f76

Browse files
Merge branch 'develop' into row-resize-feature
2 parents de58c5b + b1a3412 commit 32f9f76

5 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/lib/Behaviors/DefaultBehavior.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
handleDoubleClick,
77
getScrollOfScrollableElement,
88
isSelectionKey,
9+
getCompatibleCellAndTemplate,
910
} from "../../core";
1011
import {
1112
KeyboardEvent,
@@ -50,6 +51,8 @@ export class DefaultBehavior extends Behavior {
5051
location: PointerLocation,
5152
state: State
5253
): Behavior {
54+
const { cell } = getCompatibleCellAndTemplate(state, location);
55+
5356
// changing behavior will disable all keyboard event handlers
5457
const target = event.target as HTMLDivElement;
5558
if (
@@ -58,7 +61,7 @@ export class DefaultBehavior extends Behavior {
5861
(event.pointerType === "touch" &&
5962
(target.className === "rg-touch-column-resize-handle" ||
6063
target.className === "rg-resize-handle"))) &&
61-
location.row.idx === 0 &&
64+
(location.row.idx === 0 || cell.type === "header") &&
6265
location.column.resizable &&
6366
location.cellX >
6467
location.column.width -

src/lib/Components/CellRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export const CellRenderer: React.FC<CellRendererProps> = ({
134134
})}
135135
>
136136
{cellTemplate.render(cellToRender, isMobile ? isInEditMode : false, onCellChanged)}
137-
{location.row.idx === 0 && location.column.resizable && <ResizeColumnHandle />}
137+
{location.row.idx === 0 || (cell.type === 'header' && state.props?.enableColumnResizeOnAllHeaders)) && location.column.resizable && <ResizeColumnHandle />}
138138
{location.column.idx === 0 && location.row.resizable && <ResizeRowHandle />}
139139
{state.enableGroupIdRender && cell?.groupId !== undefined && !(isInEditMode && isMobile) && (
140140
<span className="rg-groupId">{cell.groupId}</span>

src/lib/Model/PublicModel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ export type SelectionMode =
3535
export interface ReactGridProps {
3636
/** Array of `Column`s */
3737
readonly columns: Column[];
38-
/** Array of `Row`s */
38+
/** Array of `Row`s */
3939
readonly rows: Row<Cell>[];
40+
/** Enables column resizing on all header cells */
41+
readonly enableColumnResizeOnAllHeaders?: boolean;
4042
/** Object that contains available custom cell templates */
4143
readonly customCellTemplates?: CellTemplates;
4244
/** Focus position (managed constantly by outer app) */

src/test/TestGrid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ export const TestGrid: React.FC<TestGridProps> = (props) => {
549549
rows={rows}
550550
columns={columns}
551551
initialFocusLocation={config.initialFocusLocation}
552+
enableColumnResizeOnAllHeaders={config.enableColumnResizeOnAllHeaders}
552553
focusLocation={enableFrozenFocus ? config.focusLocation : undefined}
553554
// onCellsChanged={handleChangesTest2} // TODO This handler should be allowed
554555
onCellsChanged={handleChanges}

src/test/testEnvConfig.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const config: TestConfig = {
88
pinToBody: false,
99
additionalContent: false,
1010
flexRow: false,
11+
enableColumnResizeOnAllHeaders: false,
1112

1213
rgViewportHeight: 600,
1314
rgViewportWidth: 1150,
@@ -197,6 +198,8 @@ export interface TestConfig {
197198
additionalContent: boolean;
198199
flexRow: boolean;
199200

201+
enableColumnResizeOnAllHeaders: boolean;
202+
200203
rgViewportHeight: number;
201204
rgViewportWidth: number;
202205
margin: string;

0 commit comments

Comments
 (0)