Skip to content

Commit 6b01279

Browse files
committed
Small updates
1 parent 96c9abc commit 6b01279

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

shiny/render/_data_frame.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -607,29 +607,27 @@ def _(state: BookmarkState):
607607
)
608608
state.values[cell_patch_id_val] = cell_patch_map
609609

610-
updated_data = self._updated_data()
611-
if updated_data:
610+
if self._updated_data.is_set():
612611
# TODO-barret-render.data_frame; Handle restoring updated data
613612
# Related: Restoring Chat UI: https://github.com/posit-dev/py-shiny/issues/1952
614613
raise RuntimeError(
615-
"Bookmarking an updated data frame is not supported."
614+
"Bookmarking a manually set data frame is not supported."
616615
)
617616

618-
@self._get_session().bookmark.on_restore
619-
def _(state: RestoreState):
620-
if state.input[f"{self.output_id}_cell_selection"]:
621-
self.update_cell_selection(
622-
state.input[f"{self.output_id}_cell_selection"]
623-
)
624-
if state.input[f"{self.output_id}_column_sort"]:
625-
self.update_sort(state.input[f"{self.output_id}_column_sort"])
626-
if state.input[f"{self.output_id}_column_filter"]:
627-
self.update_filter(state.input[f"{self.output_id}_column_filter"])
628-
if state.input[f"{self.output_id}_cell_selection"]:
629-
self.update_cell_selection(
630-
state.input[f"{self.output_id}_cell_selection"]
631-
)
632-
if state.input[f"{self.output_id}_data_view_rows"]:
617+
@self._get_session().bookmark.on_restored
618+
async def _(state: RestoreState):
619+
print("Available inputs:", list(state.input.keys()))
620+
cell_selection_key = f"{self.output_id}_cell_selection"
621+
column_sort_key = f"{self.output_id}_column_sort"
622+
column_filter_key = f"{self.output_id}_column_filter"
623+
if cell_selection_key in state.input:
624+
print("setting cell selection", state.input[cell_selection_key])
625+
await self.update_cell_selection(state.input[cell_selection_key])
626+
print("done setting cell selection")
627+
if column_sort_key in state.input:
628+
await self.update_sort(state.input[column_sort_key])
629+
if column_filter_key in state.input:
630+
await self.update_filter(state.input[column_filter_key])
633631

634632
cell_patch_map = state.values.get(bookmark_cell_patch_id(), None)
635633
if cell_patch_map:

tests/playwright/ai_generated_apps/bookmark/dataframe/app-express.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
from palmerpenguins import load_penguins
2+
23
from shiny import reactive
34
from shiny.express import app_opts, input, render, session, ui
45

56
penguins = load_penguins()
67

78
app_opts(bookmark_store="url")
89

10+
ui.input_bookmark_button()
11+
12+
13+
@session.bookmark.on_bookmarked
14+
async def _(url: str):
15+
await session.bookmark.update_query_string(url)
16+
917

1018
ui.h2("Palmer Penguins")
1119

@@ -70,12 +78,3 @@ def penguins_editable_df_text():
7078

7179

7280
ui.br()
73-
74-
ui.input_bookmark_button()
75-
76-
ui.br()
77-
78-
79-
@session.bookmark.on_bookmarked
80-
async def _(url: str):
81-
await session.bookmark.update_query_string(url)

0 commit comments

Comments
 (0)