Dialog: Fix height issues when calling reposition

This commit fixes an issue where if reposition is called more than once, the height of the dialog is changed on the first call and affects the calculations in subsequent calls such that for dialogs that exceed the window height, vertical scrollbars are removed erroneously.