Fixes issue when popup dialogs open in background