From 5dcec831f3bc83761d8170d25eab2cca310ae7cb Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Mon, 9 Feb 2026 09:13:31 +0100 Subject: Fix naming filter when collapsing into boxsets --- MediaBrowser.Controller/Entities/Folder.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 4916ead69a..1b574a2814 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -900,6 +900,11 @@ namespace MediaBrowser.Controller.Entities if (user is not null) { items = CollapseBoxSetItemsIfNeeded(items, query, this, user, ConfigurationManager, CollectionManager); + + // After collapse, BoxSets may have replaced items whose names matched the filter + // but the BoxSet's own name may not match. Re-apply name filtering so BoxSets + // appear under the correct letter (e.g. "Jump Street" under J, not under #). + items = ApplyNameFilter(items, query); } var filteredItems = items as IReadOnlyList ?? items.ToList(); @@ -913,6 +918,26 @@ namespace MediaBrowser.Controller.Entities return result; } + private static IEnumerable ApplyNameFilter(IEnumerable items, InternalItemsQuery query) + { + if (!string.IsNullOrWhiteSpace(query.NameStartsWith)) + { + items = items.Where(i => i.SortName.StartsWith(query.NameStartsWith, StringComparison.OrdinalIgnoreCase)); + } + + if (!string.IsNullOrWhiteSpace(query.NameStartsWithOrGreater)) + { + items = items.Where(i => string.Compare(i.SortName, query.NameStartsWithOrGreater, StringComparison.OrdinalIgnoreCase) >= 0); + } + + if (!string.IsNullOrWhiteSpace(query.NameLessThan)) + { + items = items.Where(i => string.Compare(i.SortName, query.NameLessThan, StringComparison.OrdinalIgnoreCase) < 0); + } + + return items; + } + private static IEnumerable CollapseBoxSetItemsIfNeeded( IEnumerable items, InternalItemsQuery query, -- cgit v1.2.3