# \[Widget\] Canvas slot desired size incorrect

**URL:** <https://forums.unrealengine.com/t/widget-canvas-slot-desired-size-incorrect/388897>\
**Category:** UI\
**Tags:** position, unreal-engine, Blueprint, question, UMG\
**Created:** [March 24, 2017, 6:27pm UTC](https://forums.unrealengine.com/t/widget-canvas-slot-desired-size-incorrect/388897 "2017-03-24T18:27:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MajinSephiroth](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MajinSephiroth](https://forums.unrealengine.com/u/MajinSephiroth)\
**Post date:** [March 24, 2017, 6:27pm UTC](https://forums.unrealengine.com/t/widget-canvas-slot-desired-size-incorrect/388897/1 "2017-03-24T18:27:17Z")

</div>

Having an interesting problem with widget re-positioning.

I have a widget that needs to dynamically grow in size and be positioned at construction time after it’s size increase. Having a container on a canvas allows you to “Size to content” which allows a widget to disregard it’s size instead getting the desired size, but this doesn’t seem to take effect right away. Which is a problem.

Here’s an example widget that I created to demonstrate this:

 ![131508-p1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/2/8/4282308a6ef3c7f72a955b2dce4c4b39505fc03b.png)

Here I have a simple CanvasPanel that contains a VerticalBox called container which is set to “Size to Content”

 ![131509-p2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/5/0/d50b4fb36f7bffe6284a6518c73bcd674fdcd178.png)

I created a separate widget “WBP\_SimpleImage” which contains nothing but a blank image core widget, this was just so I could have something quick to toss inside of the example widget’s VerticalBox. I’m adding 10 of them as children, after which, I print the VerticalBox’s Size as well as Desired Size. Without that delay (arbitrary number) the results are incorrect.

![131510-p3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/7/d/f7d28a6f61eae1f53fc3ef92a20ee69c29e208ba.png)

You’ll notice the VerticalBox size is correct in both cases (100, 30) but the DesiredSize is incorrect until it hits that delay.

For my purposes, when I re-position the widget it doesn’t work due to the DesiredSize not being available on the loop’s completion. With the delay there, the widget appears at 0,0 for a fraction of a second before properly being positioned which is just wrong.

What are my options to fix this glitch?

---

<div class="post-metadata">

**Author:** ![MajinSephiroth](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MajinSephiroth](https://forums.unrealengine.com/u/MajinSephiroth)\
**Post date:** [March 24, 2017, 6:53pm UTC](https://forums.unrealengine.com/t/widget-canvas-slot-desired-size-incorrect/388897/2 "2017-03-24T18:53:31Z")

</div>

So, since DesiredSize requires at least one pre-pass to have completed for any valid results to appear, I decided to tie a one time call into Tick that checks if the VerticalBox has any children, when it does fire the re-positioning call.

 ![131532-p4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/b/f9b5d204f6cc3558089fd92756a166ad27e3b2c0.png)

It’s not as ideal as I had hoped, but until I get a better solution, this will have to do. More insight into this is welcome.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4ad2f515](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4ad2f515](https://forums.unrealengine.com/u/anonymous_user_4ad2f515)\
**Post date:** [January 30, 2022, 6:05pm UTC](https://forums.unrealengine.com/t/widget-canvas-slot-desired-size-incorrect/388897/3 "2022-01-30T18:05:24Z")

</div>

Using UE5 Early Access this issue is still apparently in the engine. This can easily be seen by making a new empty user widget which has a canvas panel in it automatically. Then just add a second canvas panel under it … the second canvas panel gets this mysterious (100x30) offset that you can’t make go away and the runtime sizing is also wrong because of it.

 ![100x30-mystery](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/8/a/b8a55a0316d764d1c5f13495cfb3b5af2d83a05b.jpeg)

---

<div class="post-metadata">

**Author:** ![TylerLig](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TylerLig](https://forums.unrealengine.com/u/TylerLig)\
**Post date:** [March 11, 2023, 11:13pm UTC](https://forums.unrealengine.com/t/widget-canvas-slot-desired-size-incorrect/388897/4 "2023-03-11T23:13:46Z")

</div>

You can force a pre-pass on that widget if you want to work on it’s size without waiting as well.  
[UWidget::ForceLayoutPrepass | Unreal Engine Documentation](https://docs.unrealengine.com/5.0/en-US/API/Runtime/UMG/Components/UWidget/ForceLayoutPrepass/)
