-
-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Fix: TabBar/TabContainer can't start with all tabs deselected #108255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thygrrr
wants to merge
3
commits into
godotengine:master
Choose a base branch
from
thygrrr:tab-container-deselect-enable-fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix: TabBar/TabContainer can't start with all tabs deselected #108255
thygrrr
wants to merge
3
commits into
godotengine:master
from
thygrrr:tab-container-deselect-enable-fix
+49
−6
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KoBeWi
reviewed
Jul 4, 2025
@@ -1266,7 +1266,7 @@ void TabBar::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) { | |||
queue_redraw(); | |||
update_minimum_size(); | |||
|
|||
if (tabs.size() == 1) { | |||
if (tabs.size() == 1 && !deselect_enabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
if (tabs.size() == 1 && !deselect_enabled) { | |
if (!deselect_enabled && tabs.size() == 1) { |
Cheaper checks should be performed first.
KoBeWi
reviewed
Jul 4, 2025
Comment on lines
+112
to
+135
tab_bar->add_tab("tab2"); | ||
CHECK(tab_bar->get_tab_count() == 3); | ||
CHECK(tab_bar->get_current_tab() == -1); | ||
CHECK(tab_bar->get_previous_tab() == -1); | ||
SIGNAL_CHECK_FALSE("tab_selected"); | ||
SIGNAL_CHECK_FALSE("tab_changed"); | ||
|
||
CHECK(tab_bar->get_tab_title(0) == "tab0"); | ||
CHECK(tab_bar->get_tab_tooltip(0) == ""); | ||
CHECK(tab_bar->get_tab_text_direction(0) == Control::TEXT_DIRECTION_INHERITED); | ||
CHECK_FALSE(tab_bar->is_tab_disabled(0)); | ||
CHECK_FALSE(tab_bar->is_tab_hidden(0)); | ||
|
||
CHECK(tab_bar->get_tab_title(1) == "tab1"); | ||
CHECK(tab_bar->get_tab_tooltip(1) == ""); | ||
CHECK(tab_bar->get_tab_text_direction(1) == Control::TEXT_DIRECTION_INHERITED); | ||
CHECK_FALSE(tab_bar->is_tab_disabled(1)); | ||
CHECK_FALSE(tab_bar->is_tab_hidden(1)); | ||
|
||
CHECK(tab_bar->get_tab_title(2) == "tab2"); | ||
CHECK(tab_bar->get_tab_tooltip(2) == ""); | ||
CHECK(tab_bar->get_tab_text_direction(2) == Control::TEXT_DIRECTION_INHERITED); | ||
CHECK_FALSE(tab_bar->is_tab_disabled(2)); | ||
CHECK_FALSE(tab_bar->is_tab_hidden(2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These checks are redundant, already covered by previous subcase.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TabBars
andTabContainers
were unable to start with no tabs selected, and couldn't properly retain their current tab value of "-1", also across editor restarts.Fix for Issue:
#108223
Cause
As the tabs were added to a TabBar (or children to a TabContainer) as the scene was set up, a bug in TabBar would always select tab index 0, even if deselection was enabled.
Repro (also in linked issue):
Before fix:
Fixed via:
A missing check for
deselect_enabled
was added inTabBar.cpp
on the code path when a first tab is added to an empty bar.After fix:
Tests:
Verified on Windows only via manual testing and
./bin/godot.windows.editor.x86_64.console.exe --test --test-case="*[TabBar]*"