How to delete graphic created by Sketch on graphic focusOut ?

342
1
05-27-2020 01:02 PM
KostiaLesik
New Contributor

Hello, I have faced the next issue: after a graphic creation, I'm showing a Popup with the action "ADD" which a user should click that confirm this graphic. If the user didn't click 'add' I need to delete the graphic.
I have tried to use `sketch.delete()` on update event but it didn't work(maybe by the reason that event.state was 'completed'). Could someone help me with the issue? 

Tags (1)
0 Kudos
1 Reply
KostiaLesik
New Contributor

If someone also will be faced with such a problem, instead of using sketch.delete you need to interact with graphicsLayer.graphics:

                    graphicsLayer.graphics.items = graphicsLayer.graphics.items.filter(
                        g => g.attributes.graphicUUID !== graphicUUID
                    );
0 Kudos