Not sure. I did not use the search in header on my website, so I did not investigate it further.It's possible that this code worked for earlier SqSp version.
@arthurm above seems to be suggesting adding a search page to your header navigation menu with some added trickery. Or you could just have a page with the search function by itself? Not elegant, but functional.