Select to view content in your preferred language

Search requires selection twice and results panel doesn't auto-collapse?

2435
9
Jump to solution
07-19-2023 07:05 AM
DerekMStrout
Frequent Contributor

Hi there. I'm building a simple ExB app and have two issues with the Search widget which may be related (if not, I can post them separately). The widget is looking at two different data sources: a map layer and World Geocoding Service.

  1. The first selection the user makes from the result panel simply seems to re-filter the results (even if the original search term was an exact match for a result), requiring them to click the desired result a second time in order to trigger the other widgets.
  2. After the second (successful) selection, the results panel remains visible, obscuring the top of an Editor widget which sits directly below. This requires the user to identify and click the small Collapse button at the bottom of the results (I am using the Compact results panel option).

Am I missing some configuration option to address one or both of these issues? If not, I can add these as Ideas.

Thanks!
Derek

1 Solution

Accepted Solutions
JeffreyThompson2
MVP Frequent Contributor

Problem 1 is an easy fix. In the builder mode, open up the search result options and check 'Auto Select First Result'. 

JeffreyThompson2_0-1689777365767.png

Problem 2 is some bad design on ESRI's part. I have a fix if you are using developer edition. Open the result-list.tsx, find the onSelectRecord function and add onShowResultButtonclick()

GIS Developer
City of Arlington, Texas

View solution in original post

9 Replies
HeatherBell
Frequent Contributor

Hi @DerekMStrout

I've also noticed this, would be useful if this widget is edited. 

Thank you, 

GIS Analyst @ The Rivers Trust
JeffreyThompson2
MVP Frequent Contributor

Problem 1 is an easy fix. In the builder mode, open up the search result options and check 'Auto Select First Result'. 

JeffreyThompson2_0-1689777365767.png

Problem 2 is some bad design on ESRI's part. I have a fix if you are using developer edition. Open the result-list.tsx, find the onSelectRecord function and add onShowResultButtonclick()

GIS Developer
City of Arlington, Texas
DerekMStrout
Frequent Contributor

Wow, @JeffreyThompson2, Problem 1 seems to be working now. I swear it wasn't before, and I had "Auto Select First Result" checked. And we are using the standard ExB version (for now at least), so hopefully this is a popular request and can get implemented. Thanks for the help!

0 Kudos
CassNEGIS
Occasional Contributor

Would you happen to know why the Search widget is not selecting the matching feature when I have the result panel turned off, but works fine when it is turned on?

My experience has 2 maps, the one users interact with and one I'm using for all the fun back end stuff. The search widget is tied to a dedicated search layer in the backend map, and any selection of a feature from the Search layer is tied by actions to the layer controlling the popup as well as the corresponding feature in the user map. With the result panel turned on, it all works as expected with no snags I've come across. However, when I turn that off (so my non-empty searches can open the correct Section View) nothing happens.

0 Kudos
johnchewitt77
Emerging Contributor

Hi Jeffrey, I just wanted to say thanks for posting this as its incredibly useful. I have the same issue, and I was wondering if you could post your copy of the result-list.tsx file as I'm not totally clear what changes to make.

Thanks in advance, this is a big help.

Best wishes,

John

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

In the picture above there is a toggle switch to turn off the Result Panel, as of the latest version of ArcGIS Online, this option actually works and you can use the Search Widget with the Results Panel turned off. This should be in Developer Edition 1.16 in a week or two.

The result-list.tsx file is very long. Posting it all really wouldn't be very useful. There is a Search Widget with this modification in this package. https://community.esri.com/t5/experience-builder-custom-widgets/identify-for-experience-builder-1-14...

And this post goes into some more detail about what modifications were made and how. https://community.esri.com/t5/experience-builder-tips-and-tricks/modifying-esri-widgets-and-making-t...

GIS Developer
City of Arlington, Texas
0 Kudos
johnchewitt77
Emerging Contributor

Thanks Jeff, this is brilliant! I really appreciate the help. I followed the instructions and updated the result_list.tsx based on your code but it doesn't seem to work. My code update is below if you have time to run your eyes over it and tell me what I've done wrong. I think I may owe you some Irish Whiskey for this 😀

This is the code change I made as a result to the file at C:\ArcGis\ArcGisExperienceBuilder115\client\your-extensions\widgets\searchcustom\src\runtime\component\result_list.tsx (code change highlighted in bold)

const onSelectRecord = hooks.useEventCallback((option: SelectRecordsOption) => {

    const { isActive, recordId, dsId, configId } = option

    const localDsId = displayRecordRef.current?.[configId]?.[0]?.localDsId

    const isGeocodeRecords = displayRecordRef.current?.[configId]?.[0]?.isGeocodeRecords

    const datasourceId = isGeocodeRecords ? dsId : localDsId

    const ds = getDatasource(datasourceId) as QueriableDataSource

 

    //Publish message action

    const records = !isActive ? getRecordsByRecordsId(configId, recordId) : []

    // const widgetId = isGeocodeRecords ? id : localId

    MessageManager.getInstance().publishMessage(

      new DataRecordsSelectionChangeMessage(id, records)

    )

    handleDsIdOfSelectedResultItemChange(recordId ? dsId : null)

    if (recordId) {

      !isActive && clearOtherDsSlectedRecords(configId)

      !isActive ? ds?.selectRecordsByIds([recordId]) : ds?.selectRecordsByIds([])

    }

   //Closes search result panel

    onShowResultButtonclick()

  })

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

It's been a couple editions since I've done this, so it's possible there has been a code change along the way that broke this one line fix. I don't see any issue in the code you posted. If you turned off the Result Panel Toggle in the Build Mode try turning it back on.

Developer Edition 1.16 should be released today and it will make turning off the result panel a standard option.

GIS Developer
City of Arlington, Texas
0 Kudos
avonmoos
Regular Contributor

In AGOL search bar finds the main address on the parcel but the results panel is set to auto-select and zooms to one of the unit address on the parcel. Is there a way to setup sort or assign priority based on an attribute type?

0 Kudos