revert dialog position and protect against JS error