Skip to content

Commit 54b89b1

Browse files
Merge pull request #13052 from KacperFKorban/scaladoc/inkuire-ux-improvements
Scaladoc - Inkuire search engine UI improvements
2 parents f581090 + f8fe541 commit 54b89b1

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ object Build {
325325

326326
lazy val scalacOptionsDocSettings = Seq(
327327
"-external-mappings:" +
328-
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
328+
".*scala.*::scaladoc3::https://dotty.epfl.ch/api/," +
329329
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
330330
"-skip-by-regex:.+\\.internal($|\\..+)",
331331
"-skip-by-regex:.+\\.impl($|\\..+)",

scaladoc-js/src/searchbar/SearchbarComponent.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
167167
if selectedElement != null then {
168168
selectedElement.removeAttribute("selected")
169169
val sibling = selectedElement.previousElementSibling
170-
if sibling != null then {
170+
if sibling != null && sibling.classList.contains("scaladoc-searchbar-result") then {
171171
sibling.setAttribute("selected", "")
172172
resultsDiv.scrollTop = sibling.asInstanceOf[html.Element].offsetTop - (2 * sibling.asInstanceOf[html.Element].clientHeight)
173173
}
@@ -184,9 +184,14 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
184184
}
185185
} else {
186186
val firstResult = resultsDiv.firstElementChild
187-
if firstResult != null then {
187+
if firstResult != null && firstResult.classList.contains("scaladoc-searchbar-result") then {
188188
firstResult.setAttribute("selected", "")
189189
resultsDiv.scrollTop = firstResult.asInstanceOf[html.Element].offsetTop - (2 * firstResult.asInstanceOf[html.Element].clientHeight)
190+
} else if firstResult != null && firstResult.firstElementChild != null && firstResult.firstElementChild.nextElementSibling != null then {
191+
// for Inkuire there is another wrapper to avoid displaying old results + the first (child) div is a loading animation wrapper | should be resolved in #12995
192+
val properFirstResult = firstResult.firstElementChild.nextElementSibling
193+
properFirstResult.setAttribute("selected", "")
194+
resultsDiv.scrollTop = properFirstResult.asInstanceOf[html.Element].offsetTop - (2 * properFirstResult.asInstanceOf[html.Element].clientHeight)
190195
}
191196
}
192197
}

scaladoc/resources/dotty_res/styles/search-bar.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
width: 10px;
7676
height: 10px;
7777
border-radius: 5px;
78-
background-color: white;
79-
color: white;
78+
background-color: var(--shadow);
79+
color: var(--shadow);
8080
animation: dotFlashing 1s infinite alternate;
8181
display: inline-block;
8282
position: absolute;
@@ -104,6 +104,6 @@
104104
background-color: var(--leftbar-bg);
105105
}
106106
100% {
107-
background-color: white;
107+
background-color: var(--shadow);
108108
}
109109
}

scaladoc/src/dotty/tools/scaladoc/tasty/SymOps.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,15 @@ class SymOpsWithLinkCache:
218218
import dotty.tools.dotc
219219
given ctx: dotc.core.Contexts.Context = quotes.asInstanceOf[scala.quoted.runtime.impl.QuotesImpl].ctx
220220
val csym = sym.asInstanceOf[dotc.core.Symbols.Symbol]
221-
val extLink = if externalLinkCache.contains(csym.associatedFile) then externalLinkCache(csym.associatedFile)
222-
else {
223-
val calculatedLink = Option(csym.associatedFile).map(_.path).flatMap( path =>
224-
dctx.externalDocumentationLinks.find(_.originRegexes.exists(r => r.matches(path))))
225-
externalLinkCache += (csym.associatedFile -> calculatedLink)
226-
calculatedLink
227-
}
221+
val extLink = if externalLinkCache.contains(csym.associatedFile)
222+
then externalLinkCache(csym.associatedFile)
223+
else {
224+
val calculatedLink = Option(csym.associatedFile).map(_.path).flatMap { path =>
225+
dctx.externalDocumentationLinks.find(_.originRegexes.exists(r => r.matches(path)))
226+
}
227+
externalLinkCache += (csym.associatedFile -> calculatedLink)
228+
calculatedLink
229+
}
228230
extLink.map(link => sym.constructPath(location, anchor, link))
229231
}
230232

0 commit comments

Comments
 (0)