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

alert_dialog autoclose when refresh page #4305

Open
iBuitron opened this issue Nov 5, 2024 · 2 comments
Open

alert_dialog autoclose when refresh page #4305

iBuitron opened this issue Nov 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@iBuitron
Copy link

iBuitron commented Nov 5, 2024

Minimal exmaple

When i load the page first time, it works fine.
I click on button and then close.

if i refresh the page, it autoclose without click the button

class AlertDialogState2(rx.State):
    opened: bool = True

    def close_dialog(self):
        print("Closing dialog")
        print(self.opened)
        self.opened = False
        print(self.opened)

# Only the first time prints, on refresh just autoclose

@rx.page(
    "/synonyms/[study_id]",
    # on_load=[QuickbioState.load_qb, RadioItemsState.get_database],
)
def layout() -> rx.Component:
    return rx.alert_dialog.root(
        rx.alert_dialog.content(
            rx.alert_dialog.title("Select a database"),
            rx.box(
                # rx.radio(
                #     items=RadioItemsState.databases,
                # ),
                rx.flex(
                    rx.alert_dialog.action(
                        rx.button(
                            "Search",
                            on_click=AlertDialogState2.close_dialog,
                        ),
                    ),
                ),
            ),
        ),
        open=AlertDialogState2.opened,
    )
@iBuitron iBuitron added the bug Something isn't working label Nov 5, 2024
Copy link

linear bot commented Nov 5, 2024

@iBuitron
Copy link
Author

iBuitron commented Nov 5, 2024

https://reflex.dev/docs/library/overlay/alert-dialog/#controlling-alert-dialog-with-state

This behavior is repeated on your website.

When I open a modal, and then refresh the website, the state of the modal (open) remains despite the refresh. Is this expected behavior or a bug?
I would expect it to close and not maintain the state after the refresh.

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