Select to view content in your preferred language

Search widget in Javascript API 4.24 not firing "select-result" event for me

557
2
08-25-2022 12:44 AM
EmoryHorvath
New Contributor

I'm attempting to upgrade a web app from 4.12 to 4.24, and like usual, it seems that every single thing in Javascript API has been changed in a breaking way.

But one of the many issues i'm running into is this:  The Search widget in Javascript API 4.24 is not firing the "select-result" event for me.  It fires all the other events, but not this one.  So i can't pan to an address.

Here's a minimal code snippet for the search widget:

 

var locatorSearchWidget = new Search({
    container: "searchWidgetDiv",
    view: mapVw,
    searchAllEnabled: false,
    popupEnabled: true,
    popupOpenOnSelect: true,
    resultGraphicEnabled: false
});

locatorSearchWidget.on("select-result", function (event) {
   console.log("The selected search result: ", event);
});

 

I'm not seeing any errors displayed in the console.  The Search widget just never calls the event.

The network log shows the following correct webservice requests from the Search widget:

 

https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest?location=%7B%22spatialReference%22%3A%7B%22wkid%22%3A2926%7D%2C%22x%22%3A1276481.1570000001%2C%22y%22%3A229067.00050000002%7D&maxSuggestions=6&outSR=%7B%22latestWkid%22%3A2926%2C%22wkid%22%3A2926%7D&text=13559%2016t&f=json

https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?SingleLine=13559%2016th%20Ave%20NE%2C%20Seattle%2C%20WA%2C%2098125%2C%20USA&location=%7B%22spatialReference%22%3A%7B%22wkid%22%3A2926%7D%2C%22x%22%3A1276481.1570000001%2C%22y%22%3A229067.00050000002%7D&magicKey=dHA9MCNsb2M9MTI0NzA2NDUjbG5nPTM0I2ZhPTQ3MTg1OTIjaG49MTM1NTkjbGJzPTEwOTo1MTAyODI2MA%3D%3D&maxLocations=6&outFields=Addr_type%2CMatch_addr%2CStAddr%2CCity&outSR=%7B%22latestWkid%22%3A2926%2C%22wkid%22%3A2926%7D&f=json

 

And they appear to be returning correct json results.  But the Search widget apparently just goes off into lala land after the findAddressCandidates response.

Is there any obvious thing i'm doing wrong?

 

0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor II

Not sure what your workflow looks like, but the select-result event is firing in this sample.

https://codepen.io/odoe/pen/yLKWVVm?editors=1001

Do you have a repro? Could be something else going on.

EmoryHorvath
New Contributor

Okay, i tried your sample, and yes i see that the basic case is indeed working there.  Thanks!

Unfortunately my app is quite complex and is also restricted access.  It won't be easy to pull out a useful repro case, and i don't really have the budgeted hours available to do that, since i already burned most of the available hours dealing with this and a ton of other 4.12==>4.24 breaking changes.  At this point i'm going to have to just stick with 4.12 for now.  There's just too many remaining issues to deal with with 4.24.

But thanks anyway.

0 Kudos