Skip to content
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

Editor scene tabs do not close as expected when there are too many to fit the window #95110

Closed
ivanreyne opened this issue Aug 3, 2024 · 1 comment · Fixed by #95122
Closed

Comments

@ivanreyne
Copy link

Tested versions

  • Reproducible in 4.3rc2
  • Not reproducible in 4.2.2

System information

Godot v4.3.rc2 - TUXEDO OS 3 22.04.4 - Wayland - GLES3 (Compatibility) - Mesa Intel(R) Graphics (RPL-S) - 13th Gen Intel(R) Core(TM) i9-13900HX (32 Threads)

Issue description

This is a problem within the editor ui. When you open a scene each creates its own tab and when there are too many to fit the screen width a couple of icons appear to move/scroll the tabs themselves. At that point something weird happens because if you have the last one selected (as it happens if you just opened it) and you click its tab close button that scene does not get closed but the editor closes one of the previous ones instead.

As side note: if instead of using the tab close button, you right click the tab and use the "close tab" menu option then the right tab gets closed. So the problem seems to be related specifically to the tab's close button itlsef.

Steps to reproduce

You only need a project with enough scenes, in the following screenshots you can see I just created a new blank project and added some empty Node2D scenes (each named scene_xx to make the issue easy to follow):
Screenshot_20240803_220136

Then you just need to open many of the scenes until they do not fit the ui allocated space for tabs, in this case I opened 15 scenes:
Screenshot_20240803_221931

As the final scene opened is the "scene_15" I click its close tab button but it does not get closed, if you check the opened tabs you can see that the "scene_09" tab was closed instead:
Screenshot_20240803_222022

Clicking again the "scene_15" (still opened!) tab's close button now closes the "scene_10":
Screenshot_20240803_222035

Clicking again the "scene_15" tab's close button now closes the "scene_11":
Screenshot_20240803_222043

And clicking again the "scene_15" tab's close button now closes the "scene_12":
Screenshot_20240803_222052

And clicking again the "scene_15" tab's close button now closes the "scene_13":
Screenshot_20240803_222133

Clicking again the "scene_15" tab's close button now closes the "scene_14":
Screenshot_20240803_222142

At this point you can see that all the open scenes fit the allocated ui tab space (the tab scroll buttons are no longer present) so if I click the "scene_15" tab's close button it finally gets closed:
Screenshot_20240803_222149

Minimal reproduction project (MRP)

N/A

@kleonc
Copy link
Member

kleonc commented Aug 4, 2024

Reproducible in v4.3.dev1.official [9d1cbab].

The showcased scene tab bar issue is indeed a regression as it's not reproducible in v4.2.2.stable.official [15073af], however the root cause of the bug is actually present in there as well.

For reproducing the issue in in v4.2.2.stable.official [15073af] create a scene with a single TabBar and such script attached:

extends TabBar

func _ready() -> void:
	set_anchors_and_offsets_preset(Control.PRESET_TOP_WIDE)
	tab_close_display_policy = TabBar.CLOSE_BUTTON_SHOW_ACTIVE_ONLY
	for i in 32:
		await get_tree().create_timer(0.1).timeout
		add_tab("Tab %02d" % [i])
		current_tab = tab_count - 1
	
	tab_close_pressed.connect(func(i: int):
		print(i)
		remove_tab(i)
	)

NzlHydKDFp

The actual issue is that the tab's remove button's rect is not being cleared after the button is hidden, and mouse position is being checked against such incorrect/outdated rect, possibly deducing that incorrect tab's close button was clicked.

The underlaying issue within the TabBar was probably revealed for the scene tab bar in #83957 (guessing, haven't actually bisected) by this change:

update_scene_tabs now resizes its tabs only if it needs to, instead of always clearing and adding one by one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Development

Successfully merging a pull request may close this issue.

3 participants