From 624a544aa6a3c734846be0f07862ddf60af7235d Mon Sep 17 00:00:00 2001 From: Andrew Stein Date: Sat, 10 Apr 2021 18:13:26 -0400 Subject: [PATCH] Update regular-table to 0.3.1 --- .../perspective-viewer-datagrid/package.json | 4 +-- .../src/js/regular_table_handlers.js | 30 +++++++++++++++---- yarn.lock | 8 ++--- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/perspective-viewer-datagrid/package.json b/packages/perspective-viewer-datagrid/package.json index a4f99d0154..131f928054 100644 --- a/packages/perspective-viewer-datagrid/package.json +++ b/packages/perspective-viewer-datagrid/package.json @@ -40,9 +40,9 @@ "dependencies": { "@finos/perspective": "^0.6.2", "@finos/perspective-viewer": "^0.6.2", - "regular-table": "=0.2.1" + "regular-table": "=0.3.1" }, "devDependencies": { "@finos/perspective-test": "^0.6.2" } -} +} \ No newline at end of file diff --git a/packages/perspective-viewer-datagrid/src/js/regular_table_handlers.js b/packages/perspective-viewer-datagrid/src/js/regular_table_handlers.js index cb7e89d448..9632688958 100644 --- a/packages/perspective-viewer-datagrid/src/js/regular_table_handlers.js +++ b/packages/perspective-viewer-datagrid/src/js/regular_table_handlers.js @@ -82,8 +82,8 @@ function get_psp_type(metadata) { } } -async function sortHandler(regularTable, event) { - const meta = regularTable.getMeta(event.target); +async function sortHandler(regularTable, event, target) { + const meta = regularTable.getMeta(target); const column_name = meta.column_header[meta.column_header.length - 1]; const sort_method = event.shiftKey ? append_sort : override_sort; const sort = sort_method.call(this, column_name); @@ -149,11 +149,23 @@ async function expandCollapseHandler(regularTable, event) { } function mousedownListener(regularTable, event) { - if (event.target.classList.contains("psp-tree-label") && event.offsetX < 26) { + if (event.which !== 1) { + return; + } + + let target = event.target; + while (target.tagName !== "TD" && target.tagName !== "TH") { + target = target.parentElement; + if (!regularTable.contains(target)) { + return; + } + } + + if (target.classList.contains("psp-tree-label") && event.offsetX < 26) { expandCollapseHandler.call(this, regularTable, event); event.handled = true; - } else if (event.target.classList.contains("psp-header-leaf") && !event.target.classList.contains("psp-header-corner")) { - sortHandler.call(this, regularTable, event); + } else if (target.classList.contains("psp-header-leaf") && !target.classList.contains("psp-header-corner")) { + sortHandler.call(this, regularTable, event, target); event.handled = true; } } @@ -257,5 +269,11 @@ export async function createModel(regular, table, view, extend = {}) { export async function configureRegularTable(regular, model) { regular.addStyleListener(styleListener.bind(model, regular)); regular.addEventListener("mousedown", mousedownListener.bind(model, regular)); - await regular.draw(); + try { + await regular.draw(); + } catch (e) { + if (e.message !== "View is not initialized") { + throw e; + } + } } diff --git a/yarn.lock b/yarn.lock index a5a068b606..9bf4fe47e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14617,10 +14617,10 @@ regjsparser@^0.6.4: dependencies: jsesc "~0.5.0" -regular-table@=0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/regular-table/-/regular-table-0.2.1.tgz#af3d1efeeebe7d8071eda4e0dda689b4683ae156" - integrity sha512-24cKRtO/Gkj1p16mvqvkqWCTJSngAtFhYea7bax9XzNjTOy2DAF/507bQE+5zjq/qydfFXOUpTjnAjyIC1E5ug== +regular-table@=0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/regular-table/-/regular-table-0.3.1.tgz#68bb61a8c70c735bd223d2dbac0a1000620068af" + integrity sha512-wsJF/Jyk5ltpyRiwzbXTomiVso2xIggbB1ZH4gUW4VWIL2zdg21yIp3B0TdKyzyFSYMyayL4lF5f6Sqsa/vn8w== relateurl@0.2.x, relateurl@^0.2.7: version "0.2.7"