Skip to content

Commit 096b7cc

Browse files
committed
Use semantic elements in sidebar rstudio/bslib#580
1 parent a3a385d commit 096b7cc

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ Methods still under consideration in `shiny.experimental.ui`:
7575

7676
### Other changes
7777

78+
* `layout_sidebar()` now uses an `<aside>` element for the sidebar's container and a `<header>` element for the sidebar title. The classes of each element remain the same, but the semantic meaning of the elements is now better reflected in the HTML markup.
79+
* `layout_sidebar()` no longer gives the sidebar main content area the `role="main"` attribute.
80+
7881

7982
## [0.5.1] - 2023-08-08
8083

shiny/ui/_sidebar.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def sidebar(
244244
# bg = get_color_contrast(fg)
245245

246246
if isinstance(title, (str, int, float)):
247-
title = div(str(title), class_="sidebar-title")
247+
title = tags.header(str(title), class_="sidebar-title")
248248

249249
collapse_tag = None
250250
if open != "always":
@@ -257,7 +257,7 @@ def sidebar(
257257
aria_controls=resolved_id,
258258
)
259259

260-
tag = div(
260+
tag = tags.aside(
261261
div(
262262
title,
263263
{
@@ -270,9 +270,11 @@ def sidebar(
270270
*args,
271271
),
272272
{"class": "bslib-sidebar-input"} if resolved_id is not None else None,
273-
{"class": "sidebar"},
273+
{
274+
"class": "sidebar",
275+
"hidden": True if (open == "closed") else None,
276+
},
274277
id=resolved_id,
275-
role="complementary",
276278
class_=class_,
277279
)
278280

@@ -373,7 +375,6 @@ def layout_sidebar( # TODO-barret-API; Should this be `layout_sidebar(*args, si
373375

374376
main = div(
375377
{
376-
"role": "main",
377378
"class": f"main{' bslib-gap-spacing' if fillable else ''}",
378379
""
379380
"style": css(

0 commit comments

Comments
 (0)