Skip to content

Commit 3ef581b

Browse files
committed
Close #756: Always initialize the sidebar
1 parent 45cb389 commit 3ef581b

File tree

6 files changed

+21
-24
lines changed

6 files changed

+21
-24
lines changed

R/sidebar.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,11 @@ layout_sidebar <- function(
227227
max_height_mobile <- sidebar$max_height_mobile %||%
228228
if (is.null(height)) "250px" else "50%"
229229

230-
sidebar_init <- if (!identical(sidebar$open, "always")) TRUE
231-
232230
res <- div(
233231
class = "bslib-sidebar-layout bslib-mb-spacing",
234232
class = if (right) "sidebar-right",
235233
class = if (identical(sidebar$open, "closed")) "sidebar-collapsed",
236-
`data-bslib-sidebar-init` = sidebar_init,
234+
`data-bslib-sidebar-init` = TRUE,
237235
`data-bslib-sidebar-open` = sidebar$open,
238236
`data-bslib-sidebar-border` = if (!is.null(border)) tolower(border),
239237
`data-bslib-sidebar-border-radius` = if (!is.null(border_radius)) tolower(border_radius),
@@ -320,4 +318,3 @@ sidebar_dependency <- function() {
320318
sidebar_dependency_sass <- function(theme) {
321319
component_dependency_sass(theme, "sidebar")
322320
}
323-

inst/components/dist/sidebar/sidebar.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/components/dist/sidebar/sidebar.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/components/dist/sidebar/sidebar.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/components/dist/sidebar/sidebar.min.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

srcts/src/components/sidebar.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ class Sidebar {
8989
) as HTMLElement,
9090
} as SidebarComponents;
9191

92-
if (!this.layout.toggle) {
93-
throw new Error("Tried to initialize a non-collapsible sidebar.");
94-
}
95-
9692
const sideAccordion = this.layout.sidebar.querySelector(
9793
":scope > .sidebar-content > .accordion"
9894
);
99-
if (sideAccordion) sideAccordion.classList.add("accordion-flush");
95+
if (sideAccordion) {
96+
sideAccordion.classList.add("accordion-flush");
97+
}
10098

101-
this._initEventListeners();
102-
this._initSidebarCounters();
103-
this._initDesktop();
99+
if (this.layout.toggle) {
100+
this._initEventListeners();
101+
this._initSidebarCounters();
102+
this._initDesktop();
103+
}
104104

105105
// Start watching the main content area for size changes to ensure Shiny
106106
// outputs resize appropriately during sidebar transitions.

0 commit comments

Comments
 (0)