Interesting problem this morning. Had a container that wasn’t appearing that should always appear. App showed this behaviour when published and in Studio but, by the time the App was loaded and ready to edit in Power Apps Studio, it looked like it should be working fine.
All the variables were set as expected and the results for each control property evaluation looked right e.g. the code in .Visible was resolving to TRUE… except the .Height property was showing as 0. Weirdly, in the “canvas” view, it looked like the height was definitely non-zero as there was an outline around an apparently hidden, but large, control. For that reason I spent a long time looking at how .Visible was evaluating. Appearances were deceiving in this case!
Ignoring the evidence of my eyes, I eventually dug into what was setting Height on the control, a Context variable called containerMaxHeight, which was set by:
UpdateContext(
{
controlHeight: 30,
containerHeight: 50,
containerMaxHeight: Switch(
Settings.Size,
ScreenSize.Small,
containerHeight*2,
ScreenSize.Medium,
containerHeight,
ScreenSize.Large,
containerHeight,
containerHeight// For extra large
),
helpContainerHeight: 40,
helpContainerMaxHeight: Switch(
Settings.Size,
ScreenSize.Small,
helpContainerHeight*2,
ScreenSize.Medium,
helpContainerHeight*2,
ScreenSize.Large,
helpContainerHeight,
helpContainerHeight// For extra large
)
}
);
An experienced Power Fx/Apps user might see the problem immediately. It’s dead simple. These are all evaluated simultaneously, so they can’t depend on one another. I just needed to split the UpdateContext() function into two calls:
// have to set these first
UpdateContext(
{
controlHeight: 30,
containerHeight: 50,
helpContainerHeight: 40
}
);
// so they can be referenced here
UpdateContext(
{
containerMaxHeight: Switch(
Settings.Size,
ScreenSize.Small,
containerHeight*1.5,
ScreenSize.Medium,
containerHeight,
ScreenSize.Large,
containerHeight,
containerHeight// For extra large
),
helpContainerMaxHeight: Switch(
Settings.Size,
ScreenSize.Small,
helpContainerHeight*1.5,
ScreenSize.Medium,
helpContainerHeight*1.5,
ScreenSize.Large,
helpContainerHeight,
helpContainerHeight// For extra large
)
}
);