Hi Anand and Leo,
I’ve noticed this in the past as well. This isn’t really a theme issue, but is the default behavior of WordPress. I’m not sure if it’s bug or a feature. ๐
I’ve been using the code below in my functions.php file to halt the query if it is blank.
/**
* Halt the main query in the case of an empty search
*/
add_filter( 'posts_search', function( $search, \WP_Query $q )
{
if( empty( get_search_query() ) && $q->is_search() && $q->is_main_query() )
$search .=" AND 0=1 ";
return $search;
}, 10, 2 );
With the default GeneratePress theme, it should return the standard no-results page.
Hope this helps!