@@ -7,12 +7,17 @@ let $searchResultsContainer
77let $searchOverlay
88let $searchInput
99
10+ let isExplorerPage
11+
1012// This is our default placeholder, but it can be localized with a <meta> tag
1113let placeholder = 'Search topics, products...'
1214let version
1315let language
1416
1517export default function search ( ) {
18+ // We don't want to mess with query params intended for the GraphQL Explorer
19+ isExplorerPage = Boolean ( document . getElementById ( 'graphiql' ) )
20+
1621 // First, only initialize search if the elements are on the page
1722 $searchInputContainer = document . getElementById ( 'search-input-container' )
1823 $searchResultsContainer = document . getElementById ( 'search-results-container' )
@@ -51,7 +56,9 @@ export default function search () {
5156 searchWithYourKeyboard ( '#search-input-container input' , '.ais-Hits-item' )
5257
5358 // If the user already has a query in the URL, parse it and search away
54- parseExistingSearch ( )
59+ if ( ! isExplorerPage ) {
60+ parseExistingSearch ( )
61+ }
5562
5663 // If not on home page, decide if search panel should be open
5764 toggleSearchDisplay ( ) // must come after parseExistingSearch
@@ -133,8 +140,9 @@ async function onSearch () {
133140 const query = $searchInput . value
134141
135142 // Update the URL with the search parameters in the query string
143+ // UNLESS this is the GraphQL Explorer page, where a query in the URL is a GraphQL query
136144 const pushUrl = new URL ( location )
137- pushUrl . search = query ? new URLSearchParams ( { query } ) : ''
145+ pushUrl . search = query && ! isExplorerPage ? new URLSearchParams ( { query } ) : ''
138146 history . pushState ( { } , '' , pushUrl )
139147
140148 // If there's a query, call the endpoint
0 commit comments