Skip to content

Commit

Permalink
Fixed regression of #825 and added test.
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Feb 12, 2020
1 parent fad5c7c commit a0c67e1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/perspective-jupyterlab/src/ts/psp_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,17 @@ export class PerspectiveWidget extends Widget {
div.style.setProperty("flex-direction", "row");
node.appendChild(div);

if (!viewer.notifyResize) {
console.warn("Warning: not bound to real element");
} else {
const resize_observer = new MutationObserver(mutations => {
if (mutations.some(x => x.attributeName === "style")) {
viewer.notifyResize.call(viewer);
}
});
resize_observer.observe(node, {attributes: true});
}

return viewer;
}

Expand Down
17 changes: 17 additions & 0 deletions packages/perspective-jupyterlab/test/js/resize.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ utils.with_server({}, () => {
{wait_for_update: false}
);

test.capture(
"Resize the container causes the widget to resize",
async page => {
await page.shadow_click("perspective-viewer", "#config_button");
await page.evaluate(async () => {
document.querySelector(".PSPContainer").style = "position:absolute;top:0;left:0;width:300px;height:300px";
await document.querySelector("perspective-viewer").notifyResize();
});
await page.waitForSelector("perspective-viewer:not([updating])");
await page.evaluate(async () => {
document.querySelector(".PSPContainer").style = "position:absolute;top:0;left:0;width:800px;height:600px";
});
await page.waitForSelector("perspective-viewer:not([updating])");
},
{wait_for_update: false}
);

test.capture(
"row_pivots traitlet works",
async page => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"resize_Basic_widget_functions": "5bdf9401ae02568ae409357e7f30617b",
"resize_Resize_the_container_causes_the_widget_to_resize": "5bdf9401ae02568ae409357e7f30617b",
"resize_row_pivots_traitlet_works": "4e1404c74bd4dac4c360bc74368fd77e",
"__GIT_COMMIT__": "e3ce8edc0bb64ba3983af4035bf8e7a0e8eac584"
}

0 comments on commit a0c67e1

Please sign in to comment.