Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option to place sidebar above main content on mobile #1088

Merged
merged 7 commits into from
Jul 15, 2024

Conversation

gadenbuie
Copy link
Member

Closes #1010

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:

  1. Teaching sidebar_open_on() that "always-above" is a valid choice for the mobile component.
  2. 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.

Fixes #1081
We manually provide values to `rlang::arg_match()`, so vector input values throw
@gadenbuie gadenbuie requested a review from cpsievert July 11, 2024 19:57
@gadenbuie gadenbuie merged commit b1e0656 into main Jul 15, 2024
13 checks passed
@gadenbuie gadenbuie deleted the sidebar/always-above branch July 15, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sidebar open parameter crash Shinylive when passing a list Sidebar Panel above Main Panel in Mobile
2 participants