Skip to content

Commit 55b2a40

Browse files
committed
also allow '/' to trigger the search
1 parent 89a6409 commit 55b2a40

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scaladoc-js/src/searchbar/SearchbarComponent.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,13 @@ class SearchbarComponent(val callback: (String) => List[PageEntry]):
165165

166166
private def handleGlobalKeyDown(e: KeyboardEvent) = {
167167
// if the user presses the "S" key while not focused on an input, open the search
168-
if (e.key == "s") {
168+
if (e.key == "s" || e.key == "/") {
169169
val tag = e.target.asInstanceOf[html.Element].tagName
170170
if (tag != "INPUT" && tag != "TEXTAREA") {
171171
if (!document.body.contains(rootDiv)) {
172+
// Firefox's "quick find" uses "/" as a trigger; prevent that.
173+
e.preventDefault()
174+
172175
document.body.appendChild(rootDiv)
173176
// if we focus during the event handler, the `s` gets typed into the input
174177
window.setTimeout(() => input.focus(), 1.0)

0 commit comments

Comments
 (0)