From: Rabbi Moshe Sofer
To: Rabbi Meir Abeles
A mourner within the first three days of shivah who becomes an onen for a newly deceased relative may and must leave his home to attend the burial. The Chasam Sofer validates this ruling based on an inference from the Shach, explicit support in the Mordechai and Maharam MiRottenburg, and an analysis of the dispute between the Maharshal and Rema regarding the scope of an onen's exemption from mitzvos.
Source: Shu"t Chasam Sofer YD §325