Repository: godot
Issue: A Container Node with a RichTextLabel child will resize incorrectly if the position/size is altered on the same frame it is instanced
Labels: bug,topic:gui

### Tested versions

Tested Versions:
- Godot 4.4.beta
- Godot 4.3.stable
- Godot 4.0.stable

I think it's highly probable that this bug has been present since 4.0.

### System information

Godot v4.3.stable (77dcf97d8) - Windows 10.0.22631 - Vulkan (Forward+) - dedicated AMD Radeon RX 7900 XTX (Advanced Micro Devices, Inc.; 32.0.12033.1030) - AMD Ryzen 7 7700X 8-Core Processor (16 Threads)

### Issue description

### The Problem
This bug seems to be very specific, but consistent.

When a `Container` is instanced with a `RichTextLabel` within it, if the `Container`'s `position` or `size` are changed via scripting in the same frame it is instanced, the `RichTextLabel` will incorrectly resize itself for a single frame (?) as if it had a width of 0, rather than the width of the `Container`, therefore increasing the `Container`'s height dramatically.

**Note**: I recall this has happened to me in the past when doing other actions that aren't directly altering `position` and `size`, e.g. calling  `set_anchors_and_offsets_preset()` on the `Container`, but for reproduction purposes altering `position` will do the trick.

### Samples
A couple samples showcasing the problem using the MRP (added below).

When I run the scene without altering any `position` or `size` via code, everything works as expected, meaning the Containers have their appropriate size (set by the PackedScene data or the size of their contents).
![Image](https://github.com/user-attachments/assets/d6da5de8-0395-42e3-adad-49e9d3b47292)
(Note that the "squished and tall" `Containers` with vertical text are not bugged. I've manually set them to about ~5 width to compare heights in the sample below this one.)

In the next sample, I alter the `position` via code of the Containers I instance via code in the same frame I instance them, and the bug occurs. And, as you can see, the bugged containers match the height of their "minimal width" counterparts. I.e., the Containers became exactly as tall as needed for the `RichTextLabel` to be auto-wrapped if the Container had a width of 0.
![Image](https://github.com/user-attachments/assets/d606650c-d20f-408d-b138-cd7583eb41a5)

### Notes
This bug occurs even if there's a chain of `Containers` (child of a child of a child) with a `RichTextLabel` at the middle or end of it. The `RichTextLabel` does _not_ need to be a direct child of the moved/resized `Container` for the bug to occur. However, there _must_ be a chain of `Containers`. If there's a non-container involved, such as a regular Control, the bug does not reproduce.

Additionally, the bug occurs only if the `Container` is wider than the `RichTextLabel`'s `minimum_size`. If the RichTextLable has a `minimum_size` equal or higher than the `Container`, the bug does not occur. This matches the theory that the `RichTextLabel` resizing itself to 0 (it's minimum size) it's causing the bug: if the min_width is >= the Container's width, the bug is not observable.

### Why is this a Problem
This bug creates the issue that if you instantiate a **PackedScene** with an auto-wrapped `RichTextLabel` within a `Container` setup and move it on the same frame (an event fairly common for UI such as custom Popups or Tooltips), the Container will increase its height dramatically to accommodate the `RichTextLabel` as if it had a width of 0 (therefore auto-wrapping every single letter or word).

The only way to work around this is to call `reset_size()` on the instanced Container post-creation or waiting a 1-2 frames before editing the Container's position or size, which are workarounds with should not be necessary.

### Steps to reproduce

1. All the following steps must occur on the same frame.
2. Instantiate a `Container` (such as a `PanelContainer`) with a `RichTextLabel` as its child. This can be done by instantiating each Node separately and setting the latter as a child of the former, all via code. Alternatively, you can instantiate a PackedScene with that Node setup already prepared.
2.2. The `Container` should have a `size` or `custom_minimum_size` larger than 0. For easier bug visibility, 200x0 is recommended.
2.1. The `RichTextLabel` must have `fit_content` to `true`, `autowrap` to anything other than `off`, and have a `minimum_size` of `(0,0)`.
3. Afterwards, alter the `Container`'s `position` or `size` via code.

The result will be a `Container` that has resized its height to the `RichTextLabel` as if it had a width of 0, and since its auto-wrapped, the `RichTextLabel` becomes massively tall. On the same or next frame, the `RichTextLabel` "fixes" itself, but the `Container` remains with the excessive height.
![Image](https://github.com/user-attachments/assets/d606650c-d20f-408d-b138-cd7583eb41a5)

### Minimal reproduction project (MRP)

The following project is made in `4.4.beta`, but should work in any version down to `4.0.stable`.
In it, I messed around to gather all the data I mention above. In the main scene root, there is a script with a simple exported boolean to toggle if you want the bug to trigger or not (`position` change on the `Container`).

[ui-resize-test-4.4.beta.zip](https://github.com/user-attachments/files/18562510/ui-resize-test-4.4.beta.zip)