I have a list of streetlight data which I know is incomplete. Therefore, when users want to report an issue with a streetlight I have to let them create a new streetlight if they click anywhere on the map that doesn't have an existing feature. This is working, mostly.
The main issue I have is that I need the new streetlight to be selected as soon as it's been created. I have tried adding it to the featureTable but nothing seems to happen, and I've tried to somehow programmatically "click" on the feature to trigger the selection but I keep getting errors.
A secondary issue: I click on an empty space before anything else then the "Missing Streetlight" popup displays OK. If I select an existing feature before clicking an empty space then the popup just displays briefly and then disappears. It must be to do with the way I am showing/disabling the popups depending on what is selected or deselected but I can't quite trace where I'm going wrong.
The codepen is Selecting a New Feature (codepen.io)
The new feature issue is at line 294 and the popup issue is at line 183.
Any help fixing either of these issues would be greatly appreciated.