I switching to JavaScript 4.10, the Search widget acts funny. I have two Search widgets in my app and when the second is activated it changes the properties on the main one.
Since this is the newest api, presumably this is a bug. When I switch to 4.8 or 4.9 it works fine.
I attached some screenshots showing what I'm talking about. The placeholder for the first widgets changes when the second is created.
Solved! Go to Solution.
Hi Daniel,
Thanks for bringing this to our attention. This is a bug with the Search widget sharing the same sources. In order to fix this, can you add the following line after you create your search widgets?
searchWidget.viewModel._set("allSources", searchWidget.viewModel.allSources.clone());
This will make a clone of the `allSources` collection which will allow you to modify it without affecting the other search widget. Feel free to add this one liner to the other widget as well.
We'll get this fixed for 4.11.
Thanks!
Hi Daniel,
Thanks for bringing this to our attention. This is a bug with the Search widget sharing the same sources. In order to fix this, can you add the following line after you create your search widgets?
searchWidget.viewModel._set("allSources", searchWidget.viewModel.allSources.clone());
This will make a clone of the `allSources` collection which will allow you to modify it without affecting the other search widget. Feel free to add this one liner to the other widget as well.
We'll get this fixed for 4.11.
Thanks!
Here is a codepen too: A Pen by Matt Driscoll
If a source has resultSymbol, then it causes an error.
ERROR TypeError: "this.resultSymbol.clone is not a function"
clone /4.10/esri/widgets/Search.js:135:396
Hey Mikk, can you make sure that the resultSymbol is an instance of a symbol and not an object? What symbol type is it?
Yes, it was an object. It works with instance. Also other solution was to set it after cloning.
resultSymbol: {type: 'picture-marker', ...}
Thank you!
Thank you, Matt! That seems to work.