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

Displaying a complex HTML component breaks a dropdown control #502

Closed
mwouts opened this issue May 21, 2023 · 3 comments
Closed

Displaying a complex HTML component breaks a dropdown control #502

mwouts opened this issue May 21, 2023 · 3 comments

Comments

@mwouts
Copy link

mwouts commented May 21, 2023

This issue was first reported by @vnijs at mwouts/itables#181. When a datatables table is displayed in one tab, the dropdown control in the second tab is not displayed.

Are there some rules that we have to follow in itables when generating the HTML that have to be followed to avoid this?

Below a minimal example that reproduces the issue.

Many thanks,

from shiny import App, ui, render
import pandas as pd

from itables import to_html_datatable as DT

df = pd.DataFrame({"a": [5]})
app_ui1 = ui.page_fluid(
    # no dropdown shown in "blocked" tab
    # but the issue goes away if we just display an empty ui.HTML()
    ui.navset_tab(
        ui.nav("Tab1", ui.HTML(DT(df))),
        ui.nav(
            "Blocked",
            ui.output_ui("ui_rvar"),
        ),
    )
)


def server(input, output, session):
    @output(id="ui_rvar")
    @render.ui
    def ui_rvar():
        return ui.input_select(
            id="rvar",
            label="Response Variable",
            selected=None,
            choices=["a", "b"],
        )


app = App(app_ui1, server)
@nealrichardson
Copy link
Collaborator

nealrichardson commented Jun 6, 2023

I don't know enough about what's happening here to give an answer, but I did run this locally and could reproduce the issue. Looking at the DOM and comparing with what is inserted for simpler HTML tags, I notice that the itables renders with the <div> for the table and also a bit of <script> and loading of other assets, including jQuery (fortunately it's the same version we already loaded on the page). My guess is that something there is conflicting.

@nealrichardson
Copy link
Collaborator

I just stumbled onto rstudio/shiny#2535 (comment), which sounds similar in Shiny for R. @jcheng5 could speak with more certainty on it.

@mwouts
Copy link
Author

mwouts commented Jun 11, 2023

Thank you @nealrichardson for your comments above. They have been very helpful. Since you mention that Shiny loads jQuery already, I have just tried to remove the statement import 'https://code.jquery.com/jquery-3.6.0.min.js'; from itables when used in the context of a Shiny application... and that worked. To be released soon in itables==1.5.3.

@mwouts mwouts closed this as completed Jun 11, 2023
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

No branches or pull requests

2 participants