SketchViewModel methods turning off layerList toogle

517
2
05-31-2022 04:25 AM
AdrianaPaese
Occasional Contributor

Hello

I have an ActionToogle in a layerList item that opens/creates a featureTable and a Sketch widget at the same time - I am using the sketch widget output geometry to filter the featureTable rows. 

Whenever I click  a button to initiate the graphic´s drawing, the layerList toogle "inadvertently" turns off.

The same happens if, instead of using the sketchWidget and its default buttons, I program a custom UI as in the sample https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=sketch-viewmodel-styler 

which has sketchViewModel methods associated to calcite-action.

The buttons in the sketch menu that turn off the toogle in the layerList are those with create() or update() methods underneath. It seams that the create and update methods disable other buttons that are active in the sketch menu and in the layerList.

It would be no problem if it turned off buttons in the sketch menu only (e.g. as I click a button to draw a polygon it disables the button to draw a line).

Would there be a way of discriminating layerList and sketchWidget events so that sketchViewModel events dont affect the layer list toogle? Or would there be a way of modifying the create() or update() methods so that they dont disable other buttons by default?

Thank you very much in advance

0 Kudos
2 Replies
BenElan
Esri Contributor

It is hard to tell what is going wrong without seeing any code, but my guess is you are listening to events like 

 

document.addEventListener(...

 

If there are multiple elements that emit the same event type but their event listeners need different callback functions, then you should add the listeners directly to the specific elements. e.g.

 

document.getElementById("featureTableButton").addEventListener(...

document.getElementById("sketchButton").addEventListener(...

 

If that doesn't help, can you please provide a codepen that reproduces the issue?

0 Kudos
AdrianaPaese
Occasional Contributor

Thank you very much @BenElan

I will try and get back to you soon 

0 Kudos