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 and affects the calculations such
that for dialogs that exceed the window height, vertical scrollbars are
removed erroneously.