osu icon indicating copy to clipboard operation
osu copied to clipboard

Fix panel selection after deleting or hiding beatmaps

Open nobbele opened this issue 6 months ago • 3 comments

Closes #33536 (including my comment)

Adds a test for deleting a set and hiding a difficult, making sure it selects the new panel that replaces it.

The cleanest solution I found this was to implement it in two layers.

  • Carousel will, when an entry is deleted, select the new entry that occupies the slot the old one was in. (I don't know if this is okay to place in the general Carousel container rather than BeatmapCarousel).
  • SongSelect will, when an entry is invalidated, look for the next best difficulty in the same set, if there are valid difficulties in the set. Otherwise it will randomize the beatmap, although this shouldn't happen if the Carousel implementation works correctly.

The findNextValidBeatmap is a bit complicated, there might be a simpler way to express it, but basically it gets the next valid difficulty located after the newly hidden one. And one isn't found, it will find the previous valid difficulty before the newly one. Basically, finds the the difficulty closest to the newly hidden one.

Dealing with indexes directly is kinda ugly but it's the only thing I could come up with.

nobbele avatar Jun 10 '25 01:06 nobbele

The CodeFactor failure wasn't from my changes, I'm not sure what the right carouselItems?.Any() != true equivalent is, carouselItems == null || carouselItems.Count == 0?

nobbele avatar Jun 10 '25 01:06 nobbele

Thanks for your contribution.

That said, I would highly recommend asking before submitting relatively complex fixes for features recently released by core team members. On principle, if this is not reviewable within 10 minutes I will be closing it and implement myself as this is already on my task list.

peppy avatar Jun 10 '25 02:06 peppy

The CodeFactor failure wasn't from my changes, I'm not sure what the right carouselItems?.Any() != true equivalent is, carouselItems == null || carouselItems.Count == 0?

codefactor can generally be ignored, yeah.

peppy avatar Jun 10 '25 02:06 peppy

I'm going to review this. I've started by (hopefully) rebasing the changes on top of latest master.

peppy avatar Jul 01 '25 11:07 peppy

Added this as closing https://github.com/ppy/osu/issues/33512 as well, as it looks like it should. Will ensure test coverage is added for rulesets.

peppy avatar Jul 08 '25 08:07 peppy

Closing this as the implementation was wrong in too many ways. New PR will arrive soon.

peppy avatar Jul 09 '25 19:07 peppy