Skip to content

Commit e2558af

Browse files
authored
Merge pull request #2828 from finos/fix-switch-plugin
Fix `plugin` switch
2 parents b9af3bd + 1945b40 commit e2558af

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

packages/perspective-jupyterlab/test/jupyter/widget.spec.mts

+46
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,52 @@ perpsective.PerspectiveWidget(df, **config)
442442
expect(errored).toBe(false);
443443
});
444444

445+
test_jupyter(
446+
"Toggles to datagrid and back regression",
447+
[
448+
"w = perspective.widget.PerspectiveWidget(arrow_data, columns=['f64', 'str', 'datetime'])",
449+
"w",
450+
],
451+
async ({ page }) => {
452+
await default_body(page);
453+
const num_columns = await page
454+
.locator("regular-table thead tr")
455+
.first()
456+
.evaluate((tr) => tr.childElementCount);
457+
458+
async function toggle(plugin) {
459+
await page.locator(".plugin-select-item").click();
460+
await page
461+
.locator("#plugin_selector_container.open")
462+
.waitFor();
463+
464+
await page
465+
.locator(`[data-plugin=${plugin}].plugin-select-item`)
466+
.click();
467+
468+
await page
469+
.locator("#plugin_selector_container:not(.open)")
470+
.waitFor();
471+
472+
await page.evaluate(async () => {
473+
await document
474+
.querySelector("perspective-viewer")!
475+
.flush();
476+
});
477+
}
478+
479+
await toggle('"X/Y Line"');
480+
await toggle("Datagrid");
481+
await toggle('"X/Y Line"');
482+
await toggle("Datagrid");
483+
484+
// expect(num_columns).toEqual(3);
485+
await expect(
486+
page.locator("regular-table tbody tr")
487+
).toHaveCount(5);
488+
}
489+
);
490+
445491
// *************************
446492
// UTILS
447493
// *************************

packages/perspective-viewer-datagrid/src/js/model/toolbar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function toggle_edit_mode(mode = undefined) {
2727
}
2828

2929
this.model._edit_mode = mode;
30-
this.parentElement.setSelection();
30+
this.parentElement?.setSelection();
3131
this.model._selection_state = {
3232
selected_areas: [],
3333
dirty: true,

0 commit comments

Comments
 (0)