Skip to content

Commit 28eba7a

Browse files
committed
Fix void zone click and column resize issues
Signed-off-by: Itay Dafna <[email protected]>
1 parent 9d6d9b4 commit 28eba7a

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

js/feathergrid.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ class FeatherGridMouseHandler extends BasicMouseHandler {
129129
*
130130
* @param event - The mouse down event of interest.
131131
*/
132-
//@ts-ignore added so we don't have to add basicmousehandler.ts fork
133132
onMouseDown(grid: DataGrid, event: MouseEvent): void {
134133
const hit = grid.hitTest(event.clientX, event.clientY);
135134
const hitRegion = hit.region;
@@ -154,7 +153,7 @@ class FeatherGridMouseHandler extends BasicMouseHandler {
154153
const isMenuRow =
155154
(hit.region === 'column-header' &&
156155
hit.row ==
157-
this._grid.grid.dataModel!.rowCount('column-header') - 1) ||
156+
this._grid.grid.dataModel!.rowCount('column-header') - 1) ||
158157
(hit.region === 'corner-header' && hit.row === 0);
159158

160159
const isMenuClick =
@@ -177,6 +176,11 @@ class FeatherGridMouseHandler extends BasicMouseHandler {
177176
// Create cell config object.
178177
const config = Private.createCellConfigObject(grid, hit);
179178

179+
// Bail if no cell config object is defined for the region.
180+
if (!config) {
181+
return;
182+
}
183+
180184
// Retrieve cell renderer.
181185
const renderer = grid.cellRenderers.get(config!);
182186

@@ -206,21 +210,26 @@ class FeatherGridMouseHandler extends BasicMouseHandler {
206210
}
207211
}
208212
}
209-
//@ts-ignore added so we don't have to add basicmousehandler.ts fork
210213
super.onMouseDown(grid, event);
211214
}
212215

213-
//@ts-ignore added so we don't have to add basicmousehandler.ts fork
214216
onMouseUp(grid: DataGrid, event: MouseEvent): void {
215217
this._mouseIsDown = false;
216-
//@ts-ignore added so we don't have to add basicmousehandler.ts fork
217218
super.onMouseUp(grid, event);
218219
}
219220

220221
get mouseIsDown(): boolean {
221222
return this._mouseIsDown;
222223
}
223224

225+
get isResizing(): boolean {
226+
return (
227+
this.pressData !== null &&
228+
(this.pressData.type == 'column-resize' ||
229+
this.pressData.type == 'row-resize')
230+
);
231+
}
232+
224233
/**
225234
* A signal emitted when a grid cell is clicked.
226235
*/
@@ -285,7 +294,6 @@ export class FeatherGrid extends Widget {
285294
*/
286295
messageHook(handler: IMessageHandler, msg: Message): boolean {
287296
if (handler === this.grid.viewport) {
288-
// //@ts-ignore added so we don't have to add basicmousehandler.ts fork
289297
const mouseHandler = this.grid
290298
.mouseHandler as unknown as FeatherGridMouseHandler;
291299

@@ -945,8 +953,8 @@ export class FeatherGrid extends Widget {
945953
return this._renderers.hasOwnProperty(columnName)
946954
? this._renderers[columnName]
947955
: cellRegion === 'row-header'
948-
? this._rowHeaderRenderer
949-
: this._defaultRenderer;
956+
? this._rowHeaderRenderer
957+
: this._defaultRenderer;
950958
}
951959

952960
private _updateGridRenderers() {
@@ -958,11 +966,11 @@ export class FeatherGrid extends Widget {
958966

959967
private _updateColumnWidths() {
960968
const columnWidths = this._columnWidths;
961-
// @ts-ignore added so we don't have to add basicmousehandler.ts fork
962-
const mouseHandler = this.grid.mouseHandler as FeatherGridMouseHandler;
969+
const mouseHandler = this.grid.mouseHandler as FeatherGridMouseHandler | null;
963970

964-
// Do not want this callback to be executed when user resizes using the mouse
965-
if (mouseHandler.mouseIsDown) {
971+
// Check we have a mouse handler
972+
if (mouseHandler && mouseHandler.isResizing) {
973+
// Do not want this callback to be executed when user resizes using the mouse
966974
return;
967975
}
968976

0 commit comments

Comments
 (0)