Skip to content

Commit e4f27e4

Browse files
author
Aaron Bevill
committed
Add back restore_input() logic and add CHANGELOG.md entry for #2112
1 parent 0e965e3 commit e4f27e4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
* Fixed `ui.tooltip()`'s `options` parameter to properly pass Bootstrap tooltip options to the underlying web component. (#2101)
1717

18+
* Revised `accordion()`'s `open` logic to close all panels when an empty list is passed. (#2109)
19+
1820
## [1.5.0] - 2025-09-11
1921

2022
### New features

shiny/ui/_accordion.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,17 @@ def accordion(
255255
binding_class_value = {"class": "bslib-accordion-input"}
256256

257257
accordion_id = resolve_id_or_none(id)
258+
has_restored_input = not isinstance(
259+
restore_input(accordion_id, MISSING), MISSING_TYPE
260+
)
258261
open = restore_input(accordion_id, open)
259262

260263
is_open: list[bool]
261-
if open is None:
262-
# Open the first panel by default
264+
if has_restored_input and open is None:
265+
# None from restore_input indicates all panels closed
266+
is_open = [False] * len(panels)
267+
elif open is None:
268+
# otherwise None indicates default behavior (open first panel)
263269
is_open = [i == 0 for i in range(len(panels))]
264270
elif isinstance(open, bool):
265271
is_open = [open] * len(panels)

0 commit comments

Comments
 (0)