alert_dialog autoclose when refresh page
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,
)
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.
state is maintained across refreshes, if you want to remove that behavior in this case, either don't attach open to the state or reset it on mount