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

Tooltip-text lingers if element gets deleted from DOM #1118

Open
jmfk opened this issue Nov 28, 2024 · 0 comments
Open

Tooltip-text lingers if element gets deleted from DOM #1118

jmfk opened this issue Nov 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jmfk
Copy link

jmfk commented Nov 28, 2024

Describe the bug
I have a list of projects that each have a delete button with a Tooltip.
But when I press the button (the tooltip is active and showing) the text for the Tooltip gets hanging like a "ghost" text. It gets removed correct if the page reloads. It seems like since the definition of the Tooltip is removed it can't be cleaned up.

Screenshots

Hovering the delete button (with tooltip) for "Hello"
Image

After "Hello" is deleted
Image

Code To Reproduce

import mesop as me

projects = [
    {"key": "hello", "text": "Hello", "tooltip": "This is a tooltip"},
    {"key": "world", "text": "World", "tooltip": "This is another tooltip"},
]


@me.stateclass
class State:
    select_message: str = "Nothing yet"
    delete_message: str = "Nothing yet"


def on_reset(e: me.ClickEvent):
    global projects
    projects = [
        {"key": "hello", "text": "Hello", "tooltip": "This is a tooltip"},
        {"key": "world", "text": "World", "tooltip": "This is another tooltip"},
    ]


def on_select_project(e: me.ClickEvent):
    state = me.state(State)
    state.select_message = f"Selected: {str(e)}"


def on_delete_project(e: me.ClickEvent):
    global projects
    state = me.state(State)
    state.delete_message = f"Deleted: {str(e)}"
    projects = [p for p in projects if p["key"] != str(e.key)]


@me.page(
    path="/",
    title="Tooltip Bug",
)
def app():
    state = me.state(State)
    with me.box():
        me.text(f"select_message: {state.select_message}")
        me.text(f"delete_message: {state.delete_message}")
        me.button(
            on_click=on_reset,
            label="Reset",
        )

    for project in projects:
        with me.box():
            me.text(project["text"])
            with me.tooltip(message="Remove Project"):
                with me.content_button(
                    on_click=on_delete_project,
                    type="icon",
                    key=project["key"],
                ):
                    me.icon(icon="delete_circle")

@jmfk jmfk added the bug Something isn't working label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant