question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ChannelTabControl not handling channel closing correctly

See original GitHub issue

Right 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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thewildtreecommented, Jan 7, 2020

Thanks, that makes a lot more sense. I’ll make a PR in a minute.

0reactions
thewildtreecommented, Mar 18, 2020

Closed by #8270.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I get a close button on a templated TabItem in WPF?
I have a TabControl where the TabItem s are DataTemplat ed. The template seems to work correctly, in that the usercontrol I want...
Read more >
TabControl Class (System.Windows.Controls)
Represents a control that contains multiple items that share the same space on the screen.
Read more >
C#/WPF - Deep dive into the TabControl - YouTube
Tab Control Sample: https://github.com/Keboo/MaterialDesignInXaml.Examples/tree/master/ TabControl / TabControl.
Read more >
TabControl with customized TabItem and event handling
In this WPF Tutorial we will learn: --How to design tab window in WPF. --How to use TabControl in WPF. --How to Add...
Read more >
How to: Work with tab control - YouTube
a quick how to showing using tabcontrols quickly. check out the web ... Go to channel · How to make Modern Design form...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found