reflex-dev / reflex

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

rx.dialog.close do not trigger on button with variable color scheme #3634

Open dkaluza opened 1 week ago

dkaluza commented 1 week ago

Describe the bug Dialog does not close when button in rx.dialog.close component has color_scheme set to a state variable.

To Reproduce

  1. Create a dialog with button triggering close,
  2. Set color_scheme of the button to state variable.
  3. Try to close the dialog using the button.

Minimal example:

import reflex as rx

class State(rx.State):
    custom_color: str = "red"

def index() -> rx.Component:
    return rx.container(
rx.dialog.root(
    rx.dialog.trigger(rx.button("Dialog", size="4")),
    rx.dialog.content(
            rx.dialog.close(
                rx.button(
                    "Cancel",
                    color_scheme=State.custom_color,
                    variant="soft",
                ),
            ),
    ),
)
    )

app = rx.App()
app.add_page(index)

Expected behavior Dialog is closed correctly.

Specifics (please complete the following information):

masenf commented 1 week ago

likely duplicate of #3278

can you try wrapping your button in an rx.box and see if it works?

i have an idea for a fix for the underlying issue, but it's going to be a few weeks at least.

dkaluza commented 1 week ago

Wrapping with rx.box solves the issue, thanks for this workaround.

Great to hear it will be fixed!