Does leaving the masjid break itikaf?
If a man sitting in itikaf and his father died then can he go outside to graveyard for giving soil to him?
Leaving masjid for the following acts invalidate itikaf:
To visit a patient
To join funeral service
To perform funeral prayer
To give testimony
To go out of the masjid for an hour because of an illness
However, if it is an itikaf of offering type, and if visiting patients and being in the funeral prayer are mentioned to be the conditions of itikaf while making the intention of it, then they do not break the itikaf.
If a wajib itikaf is broken, it needs to be compensated. A nafila (supererogatory) itikaf that is abandoned after starting, according to the common view, it is not needed to be compensated. (Great Islamic Jurisprudence)