Skip to content

Commit 8b57d35

Browse files
committed
Close searchbar after clicking a result in Scaladoc
Previously the searchbar would disappear automatically after going to another URL, but would not be closed if the member was found in the current address, even if snapped to another location. Now, both events should result in the same outcome of searchbar closing.
1 parent ffe44d3 commit 8b57d35

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

scaladoc-js/main/src/searchbar/SearchbarComponent.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
2222
val resultA = document.createElement("a").asInstanceOf[html.Anchor]
2323
resultA.href = Globals.pathToRoot + p.location
2424
resultA.text = s"${p.fullName}"
25+
resultA.onclick = (event: Event) =>
26+
if (document.body.contains(rootDiv)) {
27+
document.body.removeChild(rootDiv)
28+
}
2529

2630
val location = document.createElement("span")
2731
location.classList.add("pull-right")
@@ -53,6 +57,10 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
5357
val resultA = document.createElement("a").asInstanceOf[html.Anchor]
5458
resultA.href = m.pageLocation
5559
resultA.text = m.functionName
60+
resultA.onclick = (event: Event) =>
61+
if (document.body.contains(rootDiv)) {
62+
document.body.removeChild(rootDiv)
63+
}
5664

5765
val packageDiv = document.createElement("div").asInstanceOf[html.Div]
5866
packageDiv.classList.add("scaladoc-searchbar-inkuire-package")

0 commit comments

Comments
 (0)