-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of beatmap collection changes in CollectionDropdown
#25575
Conversation
Co-authored-by: Dean Herbert <pe@ppy.sh>
I do not know how to fix the failing tests here. They are failing because they were relying on drawable menu items being iterated through and returned by The following abomination "fixes the test": diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs
index 00a0d4a849..f4c39af297 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs
@@ -250,6 +250,11 @@ private IconButton getAddOrRemoveButton(int index)
});
private IEnumerable<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem> getCollectionDropdownItems()
- => control.ChildrenOfType<CollectionDropdown>().Single().ChildrenOfType<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem>();
+ {
+ var dropdown = control.ChildrenOfType<CollectionDropdown>().Single();
+ var dropdownMenu = dropdown.ChildrenOfType<SearchContainer<Menu.DrawableMenuItem>>().Single();
+ return dropdown.ChildrenOfType<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem>()
+ .OrderBy(drawableItem => dropdownMenu.GetLayoutPosition(drawableItem));
+ }
}
}
but I will not be caught alive committing such atrocities to source, even if for test purposes. To state that this violates encapsulation would be a understatement the size of Jupiter. I am rather disappointed that this was apparently either not caught at development time, or not signposted and warned against appropriately. I would consider running tests that cover the specific modified dropdown to be a bare minimum. @frenzibyte Any bright ideas? |
I do not believe this is easily resolvable framework-side. It is expected behaviour from the lack of inserting a drawable between a container's children. Given that specific code snippet, I would've queried for EDIT: |
Which is it? And what would the changes be? If it's going to be sorting
|
Please disregard what I said about making a framework-side change, I misunderstood your original comment/intent. The |
I wrote this private IEnumerable<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem> getCollectionDropdownItems()
=> control.ChildrenOfType<CollectionDropdown>().Single().ChildrenOfType<SearchContainer<Menu.DrawableMenuItem>>().Single().FlowingChildren
.Cast<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem>(); and it still fails 4 tests while my original workaround above fails none. I'll leave it to you to figure out as I do not wish to spend any more time on this at present. |
Tests should be fixed with the above change. However, it contains a work around for an issue that is resolved by ppy/osu-framework#6079. I've made it a workaround as to not require an extra framework release, but the workaround can be reverted by just following the comment there and use |
BindableList
collection changes in dropdown osu-framework#6061Preview:
CleanShot.2023-11-25.at.02.37.38-converted.mp4