Skip to content

Commit

Permalink
Fix cell selection in Jupyter 4.0
Browse files Browse the repository at this point in the history
Signed-off-by: Vasilis Themelis <vdthemelis@gmail.com>
  • Loading branch information
vthemelis authored and martinRenou committed May 22, 2023
1 parent 783e342 commit d43d91b
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions js/mousehandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
CellRenderer,
DataGrid,
HyperlinkRenderer,
Private,
TextRenderer,
} from '@lumino/datagrid';
import { Platform } from '@lumino/domutils';
Expand Down Expand Up @@ -75,7 +74,7 @@ export class MouseHandler extends BasicMouseHandler {
}
if (grid) {
// Create cell config object.
const config = Private.createCellConfigObject(grid, hit);
const config = MouseHandler.createCellConfigObject(grid, hit);

// Bail if no cell config object is defined for the region.
if (!config) {
Expand Down Expand Up @@ -138,6 +137,34 @@ export class MouseHandler extends BasicMouseHandler {
return this._cellClicked;
}

/**
* Creates a CellConfig object from a hit region.
*/
private static createCellConfigObject(
grid: DataGrid,
hit: DataGrid.HitTestResult
): CellRenderer.CellConfig | undefined {
const { region, row, column } = hit;

// Terminate call if region is void.
if (region === 'void') {
return undefined;
}

// Augment hit region params with value and metadata.
const value = grid.dataModel!.data(region, row, column);
const metadata = grid.dataModel!.metadata(region, row, column);

// Create cell config object to retrieve cell renderer.
const config = {
...hit,
value: value,
metadata: metadata
} as CellRenderer.CellConfig;

return config;
}

private _grid: FeatherGrid;
private _mouseIsDown = false;
private _cellClicked = new Signal<this, DataGrid.HitTestResult>(this);
Expand Down

0 comments on commit d43d91b

Please sign in to comment.