ChannelTabControl not handling channel closing correctly
See original GitHub issueRight now after closing a currently active channel, ChannelTabControl always switches to the channel on its left (the previous one). However, as indicated by the comments in the code, the desired behavior would be for it to always switch to the next one (on its right side), only exception being if it was the last channel on the list.
This is also mentioned by ppy/osu-framework#3152, though as I’m not experienced enough to investigate this issue framework-wise, I wanted to focus on this specific scenario here.
This problem seems to be caused by conflicting RemoveChannel
and tabCloseRequested
functions.
tabCloseRequested
seems to launch first after closing a channel, switching the tab if the closed one was currently active. However, TabContainer.IndexOf(tab)
returns the index counting from the right side of the channel list, making the tab selecting part underneath work incorrectly (it assumes counting from the left):
if (tab == SelectedTab && totalTabs > 1)
// Select the tab after tab-to-be-removed's index, or the tab before if current == last
SelectTab(TabContainer[currentIndex == totalTabs ? currentIndex - 1 : currentIndex + 1]);
After this, RemoveChannel
’s Current.Value == channel
check is never gonna be true due to tabCloseRequested
changing the tab beforehand. Even if it did execute, it seems to only set the Current
value instead of using SelectTab()
, so it seems kinda obsolete.
I can fix this, but I’m not sure which of these functions is desired to handle the switching and if the order of items being reversed (as indicated by the IndexOf
call) is intended.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Thanks, that makes a lot more sense. I’ll make a PR in a minute.
Closed by #8270.