### Godot version

v4.2.dev3.official [013e8e3af]

### System information

Windows 10, 64bit

### Issue description

![image](https://github.com/godotengine/godot/assets/35988767/ccdac68c-a60d-491b-a406-d6e3bc1c95ae)
![GIF](https://github.com/godotengine/godot/assets/35988767/7d230faf-0260-4bc3-92e8-11cd026931a8)


### Steps to reproduce

/

### Minimal reproduction project

/
if (get_tab_count() > 0) {
		_repaint();
	} else {
		update_minimum_size();
	}
	queue_redraw();
	theme_changing = false;
}
void TabContainer::_repaint() {
	Vector<Control *> controls = _get_tab_controls();
	int current = get_current_tab();
	for (int i = 0; i < controls.size(); i++) {
		Control *c = controls[i];
		if (i == current) {
			c->show();
			c->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
			if (tabs_visible) {
				c->set_offset(SIDE_TOP, _get_top_margin());
			}
			c->set_offset(SIDE_TOP, c->get_offset(SIDE_TOP) + theme_cache.panel_style->get_margin(SIDE_TOP));
			c->set_offset(SIDE_LEFT, c->get_offset(SIDE_LEFT) + theme_cache.panel_style->get_margin(SIDE_LEFT));
			c->set_offset(SIDE_RIGHT, c->get_offset(SIDE_RIGHT) - theme_cache.panel_style->get_margin(SIDE_RIGHT));
			c->set_offset(SIDE_BOTTOM, c->get_offset(SIDE_BOTTOM) - theme_cache.panel_style->get_margin(SIDE_BOTTOM));
		} else {
			c->hide();
		}
	}
	update_minimum_size();
}
void TabContainer::_update_margins() {