Skip to content

Commit 2743bfc

Browse files
committed
Sidebar now scrolls independently, so long threads don’t trap the sidebar until the main content reaches its end
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
1 parent 9c4eaf7 commit 2743bfc

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

app/assets/stylesheets/components/sidebar.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
position: sticky;
33
top: calc(var(--nav-height) + var(--spacing-5));
44
align-self: start;
5+
max-height: calc(100vh - var(--nav-height) - var(--spacing-5));
6+
overflow-y: auto;
7+
padding-right: var(--spacing-2);
58
}
69

710
.sidebar-section {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Controller } from "@hotwired/stimulus"
2+
3+
export default class extends Controller {
4+
static targets = ["button", "menu"]
5+
6+
connect() {
7+
this.close()
8+
}
9+
10+
toggle() {
11+
if (document.body.classList.contains("nav-open")) {
12+
this.close()
13+
} else {
14+
this.open()
15+
}
16+
}
17+
18+
open() {
19+
document.body.classList.add("nav-open")
20+
if (this.hasButtonTarget) {
21+
this.buttonTarget.setAttribute("aria-expanded", "true")
22+
}
23+
}
24+
25+
close() {
26+
document.body.classList.remove("nav-open", "sidebar-open")
27+
if (this.hasButtonTarget) {
28+
this.buttonTarget.setAttribute("aria-expanded", "false")
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)