[LazyDropdownSearch] Clear selected item programatically
Forge component by Steven Decock
Application Type
Reactive

Is it possible to clear the selected item via logic? I have the following use cases;

  1. I use this dropdown to show people the current available list of items that they can add to a list. After the item has been added the list is refreshed with the now available items. The item that was previously selected is still shown although not available anymore in the list. This is confusing the users. 
  2. When using this component in an popup or sidebar and the item is reused because I open either again with a different input parameters the list is refreshed as expected (via a service call initiated in the OnParametersChanged action) but the previously selected item is still visible and possible totally incorrect in the context of the selected item. This could cause a lot of issues in our applications.

Using the SelectedItem input property does not solve this issue since that is only used during the initialization of the component. Since the item in both cases is already initialized and used this property doesn't do anything. 

An action that could be used to clear the selected property and go back to the initial state would solve all these problems (please do not fire the OnItemSelected event when doing so). 

Is it possible to add such an action?

Greetings,

Vincent

Hi Vincent,

I know you mentioned the SelectedItem property not solving the issue, but the problem seems to be solved for me by simply adding a blank Local Variable of type DropdownItem to the screen and adding it as the SelectedItem property of the LazyDropdownSearch block. I thought I would have to do additional work to get it to work, but after doing this, the selected item displayed is being cleared automatically every time the source of the SearchResultValues list is refreshed, which could be used as the trigger for clearing the selected item.

Hope this works for you too.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.