Hello all, I am working on a React app and having a difficult time trying to get the Search widget to work. I am using esri-loader and ArcGIS API for JavaScript 4.19.
I added a Search widget to my map and everything seems to be working fine up until the point when you try to click on one of the search (autocomplete) suggestions. Clicking on a suggestion closes the list of suggestions, however, the 'select-result' event never fires and the map never navigates to the selected feature. I'm trying this on a feature layer/service that supports pagination and has geometry associated with it. I'm not seeing anything in the console.
If I turn autoselect ON, the select-result event fires and the map will move, but it will always go to the first item in the suggestion list, which is not what I want.
Any ideas on why it's not working as expected with autoselect off? I'm out of ideas and not sure how to proceed.
Here is a sample of the code:
this.searchWidget = new Search({
view: this.view,
locationEnabled: false,
autoSelect: false,
includeDefaultSources: false,
sources: []
});
this.view.ui.add(this.searchWidget, { position: "top-right" });
// attached this listener; it is not firing
this.searchWidget.on("select-result", (event) => {
console.log(event);
});
this.lakes = new FeatureLayer({
id: "lakeLayer",
url: url,
definitionExpression: "state='CA'",
outFields: ["*"],
renderer: lakesRenderer,
popupTemplate: lakesTemplate
});
this.searchWidget.sources.add({
layer: this.lakes,
searchFields: ["assessmentunitname"],
displayField: "assessmentunitname",
exactMatch: false,
outFields: ["*"],
name: "Lakes & Areas",
placeholder: "Search"
});
Thank you-