fix an error preventing from toggling edit mode