fix bug: clear dialog when dialog is already cleared