[Tex/LaTex] Remove blank space before chapter heading on top of new page

etoolboxspacingtitlesec

I want chapters in the report class to start 3em below the end of the previous chapter. To do this, I patch the \chapter command using titlesec and etoolbox. However, this adds blank space above the chapter name even if is on the top of a new page, which I don't want. How can I remove the spacing if the chapter starts at the top of a new page?
I want the Sixth chapter heading like in the right hand side figure below, not the one at the left.

Actual output and wanted output

\documentclass[12pt,a4paper]{report}

\usepackage{lipsum}  
\usepackage{titlesec}  
\usepackage{etoolbox}

\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}%
    {\par\vspace{\baselineskip}}{}{}
\makeatother
\titlespacing*{\chapter}{0mm}{3em}{1em}

\begin{document}

\chapter*{First chapter}
\lipsum[1-4]
\chapter*{Second chapter}
\lipsum[1-2]
\chapter*{Third chapter}
\lipsum[2]
\chapter*{Fourth chapter}
\lipsum[1-3]
\chapter*{Fifth chapter}
\lipsum[2]
\chapter*{Sixth chapter}
\lipsum[1-2]

\end{document}

Best Answer

titlesec inserts the "traditional" forced vertical space as part of setting the chapter title header. You need to also change this \vspace* to \vspace so the space is gobbled at the start of a page:

enter image description here

\documentclass[a4paper]{report}

\usepackage{lipsum}  
\usepackage{titlesec}  
\usepackage{etoolbox}

\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}%
    {\par\addvspace{\baselineskip}}{}{}
\titlespacing*{\chapter}{0mm}{3em}{1em}
\patchcmd{\ttl@save@mkschap}{*}{}{}{}
\makeatother

\begin{document}

\chapter*{First chapter}
\lipsum[1-4]
\chapter*{Second chapter}
\lipsum[1-2]
\chapter*{Third chapter}
\lipsum[2]
\chapter*{Fourth chapter}
\lipsum[1-3]
\chapter*{Fifth chapter}
\lipsum[2]
\chapter*{Sixth chapter}
\lipsum[1-2]

\end{document}
Related Question