Skip to content

Commit e710081

Browse files
authored
Always initialize the sidebar (#795)
1 parent 45cb389 commit e710081

File tree

7 files changed

+22
-25
lines changed

7 files changed

+22
-25
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.

tests/testthat/_snaps/page.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
Output
3535
<body class="bslib-page-fill bslib-gap-spacing html-fill-container" style="padding:0px;gap:0px;--bslib-page-fill-mobile-height:auto;">
3636
<h1 class="bslib-page-title">Title</h1>
37-
<div class="bslib-sidebar-layout bslib-mb-spacing html-fill-item" data-bslib-sidebar-border="false" data-bslib-sidebar-border-radius="false" data-bslib-sidebar-open="always" data-require-bs-caller="layout_sidebar()" data-require-bs-version="5" style="--bslib-sidebar-width:250px;--bslib-sidebar-max-height-mobile:250px;">
37+
<div class="bslib-sidebar-layout bslib-mb-spacing html-fill-item" data-bslib-sidebar-border="false" data-bslib-sidebar-border-radius="false" data-bslib-sidebar-init="TRUE" data-bslib-sidebar-open="always" data-require-bs-caller="layout_sidebar()" data-require-bs-version="5" style="--bslib-sidebar-width:250px;--bslib-sidebar-max-height-mobile:250px;">
3838
<div class="main bslib-gap-spacing html-fill-container" role="main">main</div>
3939
<div role="complementary" class="sidebar">
4040
<div class="sidebar-content bslib-gap-spacing"></div>

0 commit comments

Comments
 (0)