@@ -17,6 +17,9 @@ import java.net.URI
17
17
class SearchbarComponent (engine : PageSearchEngine , inkuireEngine : InkuireJSSearchEngine , parser : QueryParser ):
18
18
val initialChunkSize = 5
19
19
val resultsChunkSize = 20
20
+
21
+ val querySearch = Option (URLSearchParams (window.location.search).get(" search" )).filter(_.nonEmpty)
22
+
20
23
def pathToRoot () = window.document.documentElement.getAttribute(" data-pathToRoot" )
21
24
extension (p : PageEntry )
22
25
def toHTML (boldChars : Set [Int ]) =
@@ -262,7 +265,8 @@ class SearchbarComponent(engine: PageSearchEngine, inkuireEngine: InkuireJSSearc
262
265
document.body.addEventListener(" keydown" , (e : KeyboardEvent ) => handleGlobalKeyDown(e))
263
266
264
267
private val inputElem : html.Input =
265
- input(cls := " scaladoc-searchbar-input" , `type` := " search" , `placeholder`:= " Find anything" ).tap { element =>
268
+ val initialValue = querySearch.getOrElse(" " )
269
+ input(cls := " scaladoc-searchbar-input" , `type` := " search" , `placeholder`:= " Find anything" , value := initialValue).tap { element =>
266
270
element.addEventListener(" input" , { e =>
267
271
clearTimeout(timeoutHandle)
268
272
val inputValue = e.target.asInstanceOf [html.Input ].value
@@ -453,3 +457,7 @@ class SearchbarComponent(engine: PageSearchEngine, inkuireEngine: InkuireJSSearc
453
457
}
454
458
455
459
inputElem.dispatchEvent(new Event (" input" ))
460
+ if (querySearch.isDefined && ! document.body.contains(rootDiv)) {
461
+ document.body.appendChild(rootDiv)
462
+ inputElem.focus()
463
+ }
0 commit comments