Skip to content

Commit

Permalink
always render, will be faster/more responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Sep 27, 2023
1 parent 49c8418 commit 2b3f636
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions solara/lab/components/confirmation_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,31 @@ def close():
on_close() # possible additional actions when closing
is_open_reactive.set(False)

if is_open_reactive.value:
with v.Dialog(
v_model=is_open_reactive.value,
on_v_model=is_open_reactive.set,
persistent=True,
max_width=max_width,
):
with solara.Card(title=title):
if isinstance(content, str):
solara.Markdown(content)
with v.Dialog(
v_model=is_open_reactive.value,
on_v_model=is_open_reactive.set,
persistent=True,
max_width=max_width,
):
with solara.Card(title=title):
if isinstance(content, str):
solara.Markdown(content)
else:
solara.display(content)
if children:
solara.display(*children)
with solara.CardActions():
if isinstance(ok, str):
solara.Button(label=ok, on_click=perform_action)
else:
solara.display(content)
if children:
solara.display(*children)
with solara.CardActions():
if isinstance(ok, str):
solara.Button(label=ok, on_click=perform_action)
solara.display(ok)
action = ok.kwargs.get("on_click")
if action:
# perform both on_ok and the on_click action of the custom Button
ok.kwargs = {**ok.kwargs, "on_click": lambda: perform_action(callback=action)}
else:
solara.display(ok)
action = ok.kwargs.get("on_click")
if action:
# perform both on_ok and the on_click action of the custom Button
ok.kwargs = {**ok.kwargs, "on_click": lambda: perform_action(callback=action)}
else:
ok.kwargs = {**ok.kwargs, "on_click": perform_action}
if isinstance(cancel, str):
solara.Button(label=cancel, on_click=close)
else:
solara.display(cancel)
ok.kwargs = {**ok.kwargs, "on_click": perform_action}
if isinstance(cancel, str):
solara.Button(label=cancel, on_click=close)
else:
solara.display(cancel)

0 comments on commit 2b3f636

Please sign in to comment.