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

shiny.ui.accordion_panel stopped working with HTML type input parameter due to changes in htmltools dependency #1827

Closed
vinaybenny opened this issue Jan 22, 2025 · 1 comment
Assignees

Comments

@vinaybenny
Copy link

vinaybenny commented Jan 22, 2025

shiny.ui.accordion_panel checks if the title parameter is an instance of str. It used to work with express.ui.HTML type input parameters, like ui.markdown. express.ui.HTML inherits from htmltools dependency. htmltools has undergone a change from version 0.6.0 wherein the HTML type no longer inherits from str. This breaks the isinstance(title, str) check that happens in the shiny.ui.accordion_panel.

With htmltools v0.5.3:
Image

With htmltools v0.6.0:
Image

@gadenbuie gadenbuie self-assigned this Jan 23, 2025
@gadenbuie
Copy link
Collaborator

Here's a small example.

from shiny import ui

ui.accordion_panel(
    ui.HTML("<em>Panel 1</em>"),
    ui.p("This is the content of Panel 1"),
)

Which returns this error message

Traceback (most recent call last):
  File "/Users/garrick/..snip../issue-1827.py", line 3, in <module>
    ui.accordion_panel(
  File "/Users/garrick/..snip../shiny/ui/_accordion.py", line 346, in accordion_panel
    raise ValueError("If `title` is not a string, `value` must be provided")
ValueError: If `title` is not a string, `value` must be provided

What this indicates is that, if title is not a string, then you need to provide the value argument, which uniquely identifies that accordion panel. So this will work:

from shiny import ui

ui.accordion_panel(
    ui.HTML("<em>Panel 1</em>"),
    ui.p("This is the content of Panel 1"),
    value="panel-1"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants