Select to view content in your preferred language

Why isn't the 'select-result' event firing when clicking a suggestion in the Search widget?

979
2
07-24-2018 11:44 AM
AlecPatrizio1
Emerging Contributor

I had a hook on the 'select-result' event when clicking a suggested result from the Search widget. It seems this event is not firing anymore when clicking a suggested result, and instead a full search is being performed.

We are using 3.25 -- i've tried with 3.24 as well.  It doesn't seem like anything changed within the Search widget from previous versions.

Is the 'select-result' event supposed to fire when clicking a suggested result ? It seems like it should since the work has already been done to retrieve the feature -- why execute another search?

Can anyone confirm this?

Update 7/25/2018:

I've tracked down the issue to a flag passed to the _hydrateResults private method of the Search class. This flag (3rd parameter of the method) is hardcoded as false in the minified code so i can't tell what this flag represents. 

When set to true, it allows feature layer search results without geometry (i.e. from a table) to be passed on as a valid results, which will then lead to the select-result event firing as appropriate.

If anyone has any info on what this flag is, it would be appreciated!

0 Kudos
2 Replies
MattDriscoll
Esri Contributor

Hi Alec,

The search widget requires features with a geometry so it's not designed to work with just a table.

That 3rd flag is for whether result is a suggestion result or not. Since suggestions don't have geometries returned, they are valid without one and a graphic without a geometry is created.

Does that help?

AlecPatrizio1
Emerging Contributor

Thanks Matt. It makes sense that the Search widget would be designed to work with feature layers that have geometry and the default behavior would require this. I've turned off the default behavior and hooked in to the suggest, search and select result events for custom behavior. I'm still not sure what changed between API versions because this wasn't an issue as of a few versions ago.

0 Kudos