reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
17.98k stars 997 forks source link

hover_card.trigger stops working when on_click event in rx.chakra.button in defined #2730

Closed Benjamin-Aw-93 closed 3 months ago

Benjamin-Aw-93 commented 4 months ago

Describe the bug When implementing the on_click event in rx.chakra.button within the rx.hover_card.root, the hover_card.trigger stops working.

To Reproduce The code is as follows:

rx.hover_card.root(
    rx.hover_card.trigger(
        rx.chakra.button("Single Search", flex_grow="1", style={"background_color": "#2e5397", "color": "white"}, size="lg", on_click=my_on_click_handler)
    ),
    rx.hover_card.content(
        rx.text("Find the SSOC code for a single job title and job description", style={"font_weight": "bold", "color": "white"}),
        side="left",
        align="center",
        style={"background": "#C55B11"}
    ),
)

my_on_click_handler just redirects the user to another page.

def my_on_click_handler():
    # Define what happens when the button is clicked
    return rx.redirect("/singlesearch")

Expected behavior The hover_card.trigger should continue to work as intended, even when the on_click event is implemented in the rx.chakra.button. The hover_card.trigger should display the hover card content when the button is hovered over, and the on_click event of the button should trigger the specified my_on_click_handler function.

Screenshots Ideally, the hover card should still appear like so: Screenshot 2024-02-27 153542

Alek99 commented 4 months ago

Thanks for pointing this out we have a fix for this coming in the next release

https://github.com/reflex-dev/reflex/pull/2793

Benjamin-Aw-93 commented 4 months ago

Thank you! Will be looking forward to the next release

picklelo commented 3 months ago

Merged in #2793