Reposition dialog after dialog size changes

In one of my dialogs I’m hiding some form items if they are not needed. When I do this the dialog (on Mac) resizes and there’s a gap at the top. Or if the dialog grows in height the dialog is positioned higher up above the title XD title bar.

Is there a method I can call to tell XD that the dialog height is changed and I need it to relayout the dialog again?

Slightly related. In Windows the dialog is popped up and centered in front of XD. On Mac the dialog slides in down from the top of title bar. For my plugins it’s better to be positioned at the top so that users can see the artboards.