Custom search in SSceneOutliner

Good day.
I need to make a menu for selecting an actor component on a level. I found how to do it, but the search bar doesn’t work quite as I expect.

Right now it seems to only show components that match the name, but only if the actor’s name also matches the search criteria.

This is how I create a scene outliner:

FSceneOutlinerInitializationOptions Options;
Options.bFocusSearchBoxWhenOpened = true;

FComponentsFilter* Filter = new FComponentsFilter(GetFilterValue(StructPropertyHandle));
SceneOutlinerFilter = MakeShareable(Filter);
Options.Filters->Add(SceneOutlinerFilter);

Options.ModeFactory.BindLambda([](SSceneOutliner* Outliner)
	{
		FActorModeParams Params;

		FActorMode* Mode = new FActorMode(Params);
		return Mode;
	});

FSceneOutlinerModule& SceneOutlinerModule = FModuleManager::Get().LoadModuleChecked<FSceneOutlinerModule>(TEXT("SceneOutliner"));
SceneOutliner = SceneOutlinerModule.CreateComponentPicker(Options, FOnComponentPicked::CreateLambda([this, StructPropertyHandle](UActorComponent* PickedComponent) { /*some actions*/}));

FComponentsFilter.h:

class FComponentsFilter : public FSceneOutlinerFilter
{
public:
	FComponentsFilter(TSubclassOf<UActorComponent> InFilterComponentClass) : FSceneOutlinerFilter(EDefaultBehaviour::Pass)
	{
		FilterComponentClass = InFilterComponentClass;
	}

	TSubclassOf<UActorComponent> FilterComponentClass;

	virtual bool PassesFilter(const ISceneOutlinerTreeItem& InItem) const override;
};

FComponentsFilter.cpp:

bool FComponentsFilter::PassesFilter(const ISceneOutlinerTreeItem& InItem) const
{
	if (!FilterComponentClass)
	{
		return false;
	}

	const FActorTreeItem& ActorItem = static_cast<const FActorTreeItem&>(InItem);

	if (ActorItem.Actor->GetClass()->IsChildOf(FilterComponentClass) || ActorItem.Actor->GetClass()->IsChildOf(AActor::StaticClass()))
	{
		return true;
	}
	
	return false;
}

How can I make it so that the actor name is ignored, filtering occurs only by component name, and actors are displayed only if their component matches the search criteria?

Thanks in advance.

BUMP

I still hope that some wise man will look in here, before I re-read half the engine code again… :grin:

BUMP

I have put off solving this problem for now, but I still wouldn’t mind if someone shared their experience in this matter. :man_mage: