Skip to content

Commit c092694

Browse files
committed
Fix entering a group moving back to the group's parent category instead of the search's root
1 parent bfa001e commit c092694

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

ComponentSelectorAdditions/DefaultHandler.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,17 @@ public static void MakePermanentButton(UIBuilder ui, LocaleString name, colorX t
116116

117117
void ICancelableEventHandler<EnumerateComponentsEvent>.Handle(EnumerateComponentsEvent eventData)
118118
{
119-
foreach (var type in eventData.RootCategory.Elements)
119+
var types = eventData.RootCategory.Elements;
120+
121+
if (eventData.Path.HasGroup)
122+
{
123+
static IEnumerable<Type> GetAllSubElements(CategoryNode<Type> category)
124+
=> category.Elements.Concat(category.Subcategories.SelectMany(GetAllSubElements));
125+
126+
types = GetAllSubElements(eventData.RootCategory);
127+
}
128+
129+
foreach (var type in types)
120130
eventData.AddItem(new ComponentResult(eventData.RootCategory, type));
121131

122132
eventData.Canceled = true;
@@ -139,7 +149,7 @@ void ICancelableEventHandler<BuildGroupButtonEvent>.Handle(BuildGroupButtonEvent
139149

140150
var category = GetPrettyPath(eventData.ItemCategory, eventData.RootCategory);
141151
var tint = RadiantUI_Constants.Sub.PURPLE;
142-
var argument = $"{eventData.ItemCategory!.GetPath()}:{eventData.Group}";
152+
var argument = $"{eventData.RootCategory!.GetPath()}:{eventData.Group}";
143153

144154
MakePermanentButton(eventData.UI, eventData.GroupName, tint, selector.OpenGroupPressed, argument, category);
145155

0 commit comments

Comments
 (0)