Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/perspective-viewer-datagrid/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare global {
interface CustomElementRegistry {
get(
tagName: "perspective-viewer-datagrid"
): HTMLPerspectiveViewerDatagridPluginElement;
): typeof HTMLPerspectiveViewerDatagridPluginElement;

// TODO is this needed?
whenDefined(tagName: "perspective-viewer-datagrid"): Promise<void>;
Expand Down
8 changes: 2 additions & 6 deletions packages/perspective-workspace/src/ts/utils/observable_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ export class ObservableMap<K, V> extends Map<K, V> {
}

delete(name: K) {
const result = this._delete_listener?.(name);
Copy link
Contributor Author

@tomjakubowski tomjakubowski Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delete listener registered by the workspace always returns undefined now, so this ended up always taking the else branch below, which skips removing the key from the map. It looks like the delete listener is not meant anymore to prevent deletes, and the workspace is the only user of this module, so I removed the conditional entirely.

if (result) {
return super.delete(name);
} else {
return false;
}
this._delete_listener?.(name);
return super.delete(name);
}

addSetListener(listener: (name: K, val: V) => void) {
Expand Down
26 changes: 26 additions & 0 deletions packages/perspective-workspace/test/js/table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,32 @@ function tests(context, compare) {
`${context}-replace-table-works-with-errored-table.txt`
);
});

test("removeTable() smoke test", async ({ page }) => {
const tables = await page.evaluate(async () => {
const table = await window.__WORKER__.table("x\n1\n");
const workspace = document.getElementById("workspace");
await workspace.addTable("temptable", table);
return Array.from(workspace.tables.keys());
});
expect(tables).toEqual(["superstore", "temptable"]);

const unknownTableResult = await page.evaluate(async () => {
return await workspace.removeTable("notatable");
});
expect(unknownTableResult).toBe(false);

const result = await page.evaluate(async () => {
return await workspace.removeTable("temptable");
});
expect(result).toBe(true);

const tablesAfterRemove = await page.evaluate(async () => {
const workspace = document.getElementById("workspace");
return Array.from(workspace.tables.keys());
});
expect(tablesAfterRemove).toEqual(["superstore"]);
});
}

test.describe("Workspace table functions", () => {
Expand Down
Loading