Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cell selection in Jupyter 4.0 #416

Merged
merged 1 commit into from
May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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