Skip to content

Commit 43d7386

Browse files
authored
Merge pull request #22926 from Joehuu/fix-sort-direction-not-resetting
Fix beatmap listing sort direction not resetting when changing criteria
2 parents a394036 + 6f3bb85 commit 43d7386

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSortTabControl.cs

+25-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
using osu.Game.Overlays;
1515
using osu.Game.Overlays.BeatmapListing;
1616
using osuTK;
17+
using osuTK.Input;
1718

1819
namespace osu.Game.Tests.Visual.UserInterface
1920
{
20-
public partial class TestSceneBeatmapListingSortTabControl : OsuTestScene
21+
public partial class TestSceneBeatmapListingSortTabControl : OsuManualInputManagerTestScene
2122
{
2223
private readonly BeatmapListingSortTabControl control;
2324

@@ -111,6 +112,29 @@ public void TestResetNoQuery()
111112
resetUsesCriteriaOnCategory(SortCriteria.Updated, SearchCategory.Mine);
112113
}
113114

115+
[Test]
116+
public void TestSortDirectionOnCriteriaChange()
117+
{
118+
AddStep("set category to leaderboard", () => control.Reset(SearchCategory.Leaderboard, false));
119+
AddAssert("sort direction is descending", () => control.SortDirection.Value == SortDirection.Descending);
120+
121+
AddStep("click ranked sort button", () =>
122+
{
123+
InputManager.MoveMouseTo(control.TabControl.ChildrenOfType<BeatmapListingSortTabControl.BeatmapTabButton>().Single(s => s.Active.Value));
124+
InputManager.Click(MouseButton.Left);
125+
});
126+
127+
AddAssert("sort direction is ascending", () => control.SortDirection.Value == SortDirection.Ascending);
128+
129+
AddStep("click first inactive sort button", () =>
130+
{
131+
InputManager.MoveMouseTo(control.TabControl.ChildrenOfType<BeatmapListingSortTabControl.BeatmapTabButton>().First(s => !s.Active.Value));
132+
InputManager.Click(MouseButton.Left);
133+
});
134+
135+
AddAssert("sort direction is descending", () => control.SortDirection.Value == SortDirection.Descending);
136+
}
137+
114138
private void criteriaShowsOnCategory(bool expected, SortCriteria criteria, SearchCategory category)
115139
{
116140
AddAssert($"{criteria.ToString().ToLowerInvariant()} {(expected ? "shown" : "not shown")} on {category.ToString().ToLowerInvariant()}", () =>

osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ protected override void LoadComplete()
2525

2626
if (currentParameters == null)
2727
Reset(SearchCategory.Leaderboard, false);
28+
29+
Current.BindValueChanged(_ => SortDirection.Value = Overlays.SortDirection.Descending);
2830
}
2931

3032
public void Reset(SearchCategory category, bool hasQuery)
@@ -102,7 +104,7 @@ public BeatmapSortTabItem(SortCriteria value)
102104
};
103105
}
104106

105-
private partial class BeatmapTabButton : TabButton
107+
public partial class BeatmapTabButton : TabButton
106108
{
107109
public readonly Bindable<SortDirection> SortDirection = new Bindable<SortDirection>();
108110

@@ -136,7 +138,7 @@ protected override void LoadComplete()
136138

137139
SortDirection.BindValueChanged(direction =>
138140
{
139-
icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown;
141+
icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending && Active.Value ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown;
140142
}, true);
141143
}
142144

osu.Game/Overlays/OverlaySortTabControl.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected override void OnDeactivated()
117117
}
118118
}
119119

120-
protected partial class TabButton : HeaderButton
120+
public partial class TabButton : HeaderButton
121121
{
122122
public readonly BindableBool Active = new BindableBool();
123123

0 commit comments

Comments
 (0)