From 71d8873cb32df1139691fddcb74a02bfa666afd2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Aug 2025 03:13:59 +0900 Subject: [PATCH] Fix keyboard selection being reset/invalidated more often than required --- osu.Game/Graphics/Carousel/Carousel.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/Carousel/Carousel.cs b/osu.Game/Graphics/Carousel/Carousel.cs index c96afacd59..414aba1a2e 100644 --- a/osu.Game/Graphics/Carousel/Carousel.cs +++ b/osu.Game/Graphics/Carousel/Carousel.cs @@ -113,14 +113,21 @@ namespace osu.Game.Graphics.Carousel if (currentSelection.Model != null) HandleItemDeselected(currentSelection.Model); - currentKeyboardSelection = new Selection(value); - currentSelection = currentKeyboardSelection; + currentSelection = new Selection(value); + currentKeyboardSelection = currentSelection; selectionValid.Invalidate(); } - else if (currentKeyboardSelection.Model != value) + + // Check keyboard selection equality separately. + // + // If current selection set to an already-selected value, we want to ensure + // that keyboard selection (which basically represents the "visual" tracking of selection) + // is still reset back to the newly set value. + // + // The main case this handles is when a set header is clicked and we want to make sure one of its + // "children" are re-selected. + if (!CheckModelEquality(currentKeyboardSelection.Model, value)) { - // Even if the current selection matches, let's ensure the keyboard selection is reset - // to the newly selected object. This matches user expectations (for now). currentKeyboardSelection = currentSelection; selectionValid.Invalidate(); }