Skip to content

Commit a78ab83

Browse files
committed
fix theme initialization problem
1 parent 3557502 commit a78ab83

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/datagrid.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ export
268268
class DataGridView extends DOMWidgetView {
269269
_createElement(tagName: string) {
270270
this.pWidget = new JupyterPhosphorPanelWidget({ view: this });
271+
// initialize to light theme unless set earlier
272+
this._isLightTheme = this._isLightTheme === undefined ? true : this._isLightTheme;
271273
return this.pWidget.node;
272274
}
273275

@@ -292,6 +294,7 @@ export
292294
this.grid.dataModel = this.model.data_model;
293295
this.grid.selectionModel = this.model.selectionModel;
294296
this.grid.editable = this.model.get('editable');
297+
this.grid.isLightTheme = this._isLightTheme;
295298

296299
this.grid.cellClicked.connect((sender: FeatherGrid, event: FeatherGrid.ICellClickedEvent) => {
297300
if (this.model.comm) {
@@ -404,6 +407,9 @@ export
404407

405408
set isLightTheme(value: boolean) {
406409
this._isLightTheme = value;
410+
if (!this.grid) {
411+
return;
412+
}
407413
this.grid.isLightTheme = value;
408414
}
409415

@@ -427,7 +433,8 @@ export
427433
grid: FeatherGrid;
428434
pWidget: JupyterPhosphorPanelWidget;
429435
model: DataGridModel;
430-
private _isLightTheme: boolean = true;
436+
// keep undefined since widget initializes before constructor
437+
private _isLightTheme: boolean;
431438
}
432439

433440
export {

0 commit comments

Comments
 (0)