okld / streamlit-elements

Create a draggable and resizable dashboard in Streamlit, featuring Material UI widgets, Monaco editor (Visual Studio Code), Nivo charts, and more!
MIT License
734 stars 82 forks source link

Usage of mui.Tooltip throws ElementsFrontendError #6

Closed Toxiiin closed 1 year ago

Toxiiin commented 2 years ago

Hi everyone, hi @okld,

I was trying to use some tooltips with the mui.Tooltip element, but if I do, it throws an ElementsFrontendError:

ElementsFrontendError: In elements frame 'streamlit_elements.core.frame.elements_frame.tooltip_test': Cannot read properties of undefined (reading 'addEventListener')

I have used the following snippet:

with elements("tooltip_test"):
    with mui.Tooltip(title="Tooltip"):
        mui.Typography(
            "Tooltip"
        )

Is there something I missed?

Expected Behavior

Tooltip shows up as expected.

Current Behavior

Usage of mui.Tooltip results in an ElementsFrontendError.

ElementsFrontendError: In elements frame 'streamlit_elements.core.frame.elements_frame.tooltip_test': Cannot read properties of undefined (reading 'addEventListener')

Steps to Reproduce

  1. Use the mui.Tooltip element in your script like:
    with elements("tooltip_test"):
        with mui.Tooltip(title="Tooltip"):
            mui.Typography(
                "Tooltip"
            )

Context (Environment)

Sanuki-073 commented 1 year ago

Hello @Toxiiin,

I found the answer of this issue.

from streamlit_elements import html
# import others
....

with elements("tooltip_test"):
    with mui.Tooltip(title="Tooltip"):
        with html.span:
            mui.Typography(
                 "Tooltip"
            )
Toxiiin commented 1 year ago

Hi @Sanuki-073,

never thought would get an answer after this time. 😃 Thank you for sharing the answer! 👍