When using FString property with GetOptions meta specifier, and resetting the property to default, user is unable to reselect the option that was previously selected. Repro steps are provided above.
Steps to Reproduce
- Create an FString MyString and mark it as UPROPERTY
- Add “GetOptions” meta specifier and define a function to get options from, e.g. Option1, Option2, Option3
- In editor, select an option, e.g. Option1
- Observe MyString being updated
- Reset MyString to default using “Reset to default” button
- Try to reselect the same option as before
- Observe nothing happens
Cause: SSearchableComboBox caches SelectedItem. When resetting property to Default, ProposedSelection passed into SSearchableComboBox::OnSelectionChanged_Internal is a nullptr, so the function is ignored, and SelectedItem is not updated. When trying to reselect actual value, it checks ProposedSelection against SelectedItem, sees they are the same and does not trigger the chain of events required to update the property.
Attempted fix: get a created widget directly using IPropertyCustomization and try to update the property using SetSelectedItem manually upon resetting property to default. This failed because SetSelectedItem relies on ComboList, which is only created when the Searchable Combo Box is opened, and destroyed when it’s closed, so the manual calls to SetSelectedItem crash the editor.
Our current fix: If ProposedSelection is nullptr, set SelectedItem to nullptr as well.
Hi,
Thanks for the report. It seems like it should be sufficient to just clear out the cached value when the SearchableComboBox is cleared:
void SSearchableComboBox::ClearSelection() { ComboListView->ClearSelection(); SelectedItem = nullptr; }
That should be a bit safer since it also covers cases of ClearSelection being called manually, but let me know if you have any concerns. I can see about getting that checked in, though it likely won’t make it until 5.7.
Best,
Cody
Hi Cody,
Thanks for replying! That indeed works, too. Thank you for taking care of that. Have a great day!