Grid slots don't resize correctly when populating a grid from script

When I try to populate a grid by instantiating the slots and parenting them to the grid, if I run the game at a resolution that is different from the “Referenced resolution”, the slots are not resized correctly. I’ve tried both transform.parent = … and transform.SetParent().

On the screenshot the 1st slot was there already before the game started and its size is correct, the others were instantiated.

What’s funny is that the other slots show in the Inspector (in grayed out font) that they are the same width/height as the first one!

Note that if I manually drag the prefab and parent it while in game or duplicate it with ctrl-D, it is resized just fine. I can submit a bug, but how to fix this without waiting for the next build? Maybe there’s a way to mimic what happens when I ctrl-D the slot from within the grid?

Please submit a bug, not sure of what it is until I see the project.