This PR adds a new "always-above" option for the mobile component of sidebar(open=), in other words:
# Page with sidebar permantenly open below main content on mobile
page_sidebar(
sidebar = sidebar("Sidebar"),
"Main content"
)
# Page with sidebar permanently open **above** main content on mobile
page_sidebar(
sidebar = sidebar("Sidebar", open = list(mobile = "always-above")),
"Main content"
)
This feature works by:
Teaching sidebar_open_on() that "always-above" is a valid choice for the mobile component.
Reversing the order of main and sidebar in the markup when open$mobile == "always-above".
This won't change visual order for screens above mobile size, where the layout is determined by grid. It will, however, result in the sidebar receiving tab focus before the main content area, across all screen sizes. That seems a reasonable trade-off and in-line with the types of UIs where users would want the sidebar to be shown before the main content on mobile devices.
Fixes #1081
Incidentally, I ran into the problem described in #1081 while working on this. The issue turns out to be that we manually provide values to rlang::arg_match(), so calling sidebar_open_on() without arguments could potentially throw. The fix is to use scalar default values in that helper function.
Closes #1010
This PR adds a new
"always-above"
option for themobile
component ofsidebar(open=)
, in other words:This feature works by:
sidebar_open_on()
that"always-above"
is a valid choice for themobile
component.main
andsidebar
in the markup whenopen$mobile == "always-above"
.This won't change visual order for screens above mobile size, where the layout is determined by
grid
. It will, however, result in the sidebar receiving tab focus before the main content area, across all screen sizes. That seems a reasonable trade-off and in-line with the types of UIs where users would want the sidebar to be shown before the main content on mobile devices.Fixes #1081
Incidentally, I ran into the problem described in #1081 while working on this. The issue turns out to be that we manually provide values to
rlang::arg_match()
, so callingsidebar_open_on()
without arguments could potentially throw. The fix is to use scalar default values in that helper function.