Skip to content

Commit f49cb04

Browse files
authored
Merge pull request #13 from szymon-rd/current-page-inactive-link
current page link click no reload
2 parents 3732466 + 378a478 commit f49cb04

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

scaladoc/resources/dotty_res/scripts/ux.js

+6-15
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,19 @@ window.addEventListener("DOMContentLoaded", () => {
4444
}
4545
}
4646

47-
$(".side-menu span").on('click', function () {
48-
$(this).parent().toggleClass("expanded")
49-
});
50-
5147
$(".ar").on('click', function (e) {
5248
$(this).parent().parent().toggleClass("expanded")
5349
$(this).toggleClass("expanded")
5450
e.stopPropagation()
5551
});
5652

5753
document.querySelectorAll(".nh").forEach(el => el.addEventListener('click', () => {
58-
el.lastChild.click()
59-
el.first.addClass("expanded")
60-
el.parent.addClass("expanded")
54+
if (el.lastChild.href.replace("#", "") === window.location.href.replace("#", "")) {
55+
el.parentElement.classList.toggle("expanded")
56+
el.firstChild.classList.toggle("expanded")
57+
} else {
58+
el.lastChild.click()
59+
}
6160
}))
6261

6362
document.querySelectorAll(".supertypes").forEach(el => el.firstChild.addEventListener('click', () => {
@@ -71,12 +70,6 @@ window.addEventListener("DOMContentLoaded", () => {
7170
el.firstChild.classList.toggle("expand");
7271
}))
7372

74-
document.querySelectorAll(".nh").forEach(el => el.addEventListener('click', () => {
75-
el.lastChild.click()
76-
el.first.addClass("expanded")
77-
el.parent.addClass("expanded")
78-
}))
79-
8073
const observer = new IntersectionObserver(entries => {
8174
entries.forEach(entry => {
8275
const id = entry.target.getAttribute('id');
@@ -92,8 +85,6 @@ window.addEventListener("DOMContentLoaded", () => {
9285
observer.observe(section);
9386
});
9487

95-
document.querySelectorAll(".side-menu a").forEach(elem => elem.addEventListener('click', e => e.stopPropagation()))
96-
9788
if (location.hash) {
9889
var target = location.hash.substring(1);
9990
// setting the 'expand' class on the top-level container causes undesireable styles

scaladoc/src/dotty/tools/scaladoc/renderers/HtmlRenderer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
137137
Seq(
138138
span(cls := s"nh " + attrs.mkString(" "))(
139139
if withArrow then Seq(button(cls := s"ar icon-button ${if isSelected || expanded then "expanded" else ""}")) else Nil,
140-
a(href := pathToPage(pageLink.dri, nav.link.dri))(icon, span(name))
140+
a(href := (if isSelected then "#" else pathToPage(pageLink.dri, nav.link.dri)))(icon, span(name))
141141
)
142142
)
143143

scaladoc/test/dotty/tools/scaladoc/site/NavigationTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class NavigationTest extends BaseHtmlTest:
2525
NavMenuTestEntry("A directory", "dir/index.html", Seq(
2626
NavMenuTestEntry("Nested in a directory", "dir/nested.html", Nil)
2727
)),
28-
NavMenuTestEntry("Adoc", "Adoc.html", Seq())
28+
NavMenuTestEntry("Adoc", "#", Seq())
2929
)
3030

3131
val apiNav = Seq(
32-
NavMenuTestEntry("tests.site", "site.html", Seq(
32+
NavMenuTestEntry("tests.site", "#", Seq(
3333
NavMenuTestEntry("some.other", "site/some/other.html", Seq(
3434
NavMenuTestEntry("SomeOtherPackage", "site/some/other/SomeOtherPackage.html", Nil),
3535
)),

0 commit comments

Comments
 (0)