I am displaying a VF page embedded in a page layout. I am using $User.UIThemeDisplayed to display the content only in Classic, not in Lightning. But when I view the page in Lightning, it still shows the empty space where the VF page would display, equal to the size of the Height I have setup for the VF page. The question is, is there a way to do this so that the empty space is not displayed?
1 Answer
Based on all my experiences, I can say there's no way to hide it.
Anything on the page layout takes a "real estate" and is static in nature. It does not re-arrange dynamically if one or other component is not applicable.
Let's say if there are some fields on the page layout which are not supposedly visible to a particular profile, the fields won't be re-arranged and that empty spaces will fill in there. However, if there are fields in a particular section, and that the user doesn't have access to any of them, then the section is not displayed either.
In case of VF page in a section, because the dimensions are statically mentioned, depending if it has contents to be displayed or not, it still will be shown on the page. And if a User doesn't have access to that VF page, the section displays a message mentioning insufficient privileges.
So, ultimately it looks like you don't have an option of hiding/reducing the size of the section.