Skip to content

Commit ec3131e

Browse files
committed
Search Blocks overlay: auto-open on initial page load when URL has ?s=keyword (SEARCH-232)
The existing handlePopState() already maps URL → overlay visibility for back/ forward navigation. Wire it to the initial-paint URL too so deep links and the WordPress core search form's GET submission surface results in the blocks- powered overlay the same way they do in the legacy instant-search overlay.
1 parent 3150567 commit ec3131e

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Search Blocks overlay: auto-open on initial page load when the URL contains `?s=` or `?q=`, matching the legacy instant-search overlay's deep-link behavior.

projects/packages/search/src/search-blocks/overlay-bootstrap/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,13 @@ const overlayEl = getOverlay();
298298
if ( overlayEl ) {
299299
overlayEl.addEventListener( 'click', handleOverlayClick );
300300
}
301+
302+
// Honor the URL on initial paint the same way `popstate` does on back/forward:
303+
// if the page loaded with `?s=` or `?q=`, open the overlay. This matches the
304+
// legacy instant-search behavior where deep links and core-search-form GET
305+
// submissions surface results in the overlay without a click.
306+
if ( document.readyState === 'loading' ) {
307+
document.addEventListener( 'DOMContentLoaded', handlePopState, { once: true } );
308+
} else {
309+
handlePopState();
310+
}

0 commit comments

Comments
 (0)