Dropdown Dynamic Simple Widget + Searchable - only shows values filtered by looked up field

Feature(s) impacted

Using the Dropdown Widget, with dynamic data in simple mode and with the searchable mode - will actually search by the field the drop down users AND the “reference field” of the target collection.

BUT it would not show the values even if documents are found if they are not from the dropdown configured field.

Observed behavior

Only if the searched value is from the field used by the dropdown - results are shown.

Here is a detailed example.
Assume collection named makers that has the fields name and id.
Assume a field called makerId on some entity - that is configured to lookup “makers” from the above collection.

To do that we define the widget so:
Edit Widget - Dropdown (Type - Dynamic, Values - Simple, Collection - makers, field - id)
“Enable Search” is true.

The makers collection is configured to use the name field as the value shown when referenced.

Now, when the user types into the makerId field to lookup makers - the system would issue the following search (mongodb here):

makers.aggregate([ { '$match': { '$and': [ { '$or': [ { name: /.*erik.*/i }, { id: /.*erik.*/i } ] } ] } }, { '$skip': 0 }, { '$limit': 100 }], {})

As you see, makers with names like erik are found - and indeed returned from the API to the forest app. BUT the widget dropdown will not show those results - since the id of all those makers does not match the erik string (presumably)


Again - actual results from the API do include makers here - so I must assume the widget locally has a matching (simple search) against the list of ids the API returned to further narrow down the list of options displayed.

Expected behavior

Results (id values in the above scenario) are shown for any match on the searched value.



Hey @Yoad_Snapir

As usual, a complete explanation/analysis of the issue, always appreciated :pray:

I can totally reproduce the behavior you are describing on my end. The dynamic simple dropdown was initially not developed to allow full model search (Even though results may be returned from your database matching this search), but more to allow to re-use fields from a collection to another.

The best workaround I can propose would be to switch to a dynamic smart dropdown in order to implement the behavior you expect.

In the meantime, I’ll sync with the team to better understand if there is a specific reason why this was done this way (Or if this is indeed a bug), and I’ll let you know :pray:

Perfect, I would of course consider implementing smart relationship here - and most likely that could cover all my needs. But I wanted to get a quick solution and the Dropdown widget is such.

If it would cover the mentioned ability - it would make for even a better “free magic” - which Forest is all about :slight_smile:

@Yoad_Snapir :wave:

After further discussion with the team, it seems like this fall in the feature request category, since the dynamic simple dropdown configured was designed with highlighted search in the dropdown in mind.
I’m switching the category of this thread & I’ll push this as a product board suggestion.

However, it seems like the default behavior indeed does a search request instead of a filter, which is a performance issue, and I’m opening a ticket on our end.

Sorry for the inconvenience :pray:

1 Like