Skip to content

page_sidebar and page_navbar should drop sidebar parameter and accept Sidebar objects in *args #939

@wch

Description

@wch

Currently, page_sidebar() and page_navbar() take an explicit sidebar argument.

However, for page_auto(), which is used in Express mode, there's no sidebar argument (because children can't be passed as named arguments in Express). Instead, we inspect the *args, pull out any Sidebar objects, and then explicitly pass them to the sidebar argument.

py-shiny/shiny/ui/_page.py

Lines 529 to 530 in a020af6

page_fn = page_sidebar # pyright: ignore[reportGeneralTypeIssues]
args = tuple(sidebars + [x for x in args if x not in sidebars])

Also, because of how Python handles named and unnamed ages:

  • For page_sidebar(), the signature is page_sidebar(sidebar, *args). This means that the sidebar must be the first argument and must not be named.
  • For page_navbar(), the signature is page_navbar(*args, sidebar). This means that the sidebar must not be the first argument, and must be named.

I think we should remove the sidebar parameter from these functions and simply inspect the *args for Sidebar objects -- essentially, take the logic from page_auto() and move it into page_sidebar() and page_navbar().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions