From e79d8553e70c84f2aa34d164779e7f28756c7497 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Thu, 14 Sep 2023 06:33:14 +0200 Subject: [PATCH] refactor: simplify overlay management in JS bridge code Call the new `getModelElementsByIds` method introduced in bpmn-visualization@0.39.0 --- inst/htmlwidgets/bpmnVisualizationR.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inst/htmlwidgets/bpmnVisualizationR.js b/inst/htmlwidgets/bpmnVisualizationR.js index ff0d1e3..c08e705 100644 --- a/inst/htmlwidgets/bpmnVisualizationR.js +++ b/inst/htmlwidgets/bpmnVisualizationR.js @@ -64,9 +64,9 @@ HTMLWidgets.widget({ const overlayConfig = {...rest}; if(enableDefaultOverlayStyle && !(overlayConfig.style && overlayConfig.position)) { - const elementsByIds = bpmnVisualization.bpmnElementsRegistry.getElementsByIds(elementId); - if (elementsByIds.length) { - const isShape = elementsByIds[0].bpmnSemantic.isShape; + const elements = bpmnVisualization.bpmnElementsRegistry.getModelElementsByIds(elementId); + if (elements.length) { + const isShape = elements[0].isShape; overlayConfig.style ??= buildDefaultOverlayStyle(isShape); overlayConfig.position ??= buildDefaultOverlayPosition(isShape); } @@ -80,7 +80,7 @@ HTMLWidgets.widget({ }, // Make the bpmnVisualization object available as a property on the widget instance we're returning from factory(). - // This is generally a good idea for extensibility--it helps users of this widget interact directly with bpmnVisualization, if needed. + // This is generally a good idea for extensibility: it helps users of this widget to interact directly with bpmnVisualization, if required. s: bpmnVisualization }; }