[IMP]code improvement and Not open Dialog on mouseleave if  edit mode