Skip to content

fix: write the bookmark URL to the address bar instead of a Bootstrap modal - #334

Open
schloerke wants to merge 1 commit into
schloerke/use-shiny-connectedfrom
schloerke/bookmark-default
Open

schloerke wants to merge 1 commit into
schloerke/use-shiny-connectedfrom
schloerke/bookmark-default

Conversation

@schloerke

@schloerke schloerke commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes posit-dev/shinyreact#326.

Shiny's default onBookmarked / on_bookmarked action shows the URL in a Bootstrap modal. page_react() loads no Bootstrap, so session$doBookmark() / session.bookmark() threw $(...).modal is not a function and the URL was never shown or updated.

The per-session shinyreact.init handler (R and Python) now registers a default onBookmarked callback that writes the URL to the address bar (updateQueryString() / update_query_string()).

Shiny only runs its own default when no callback is registered, and runs every callback otherwise. So this callback only acts while it is the only one. If the app registers its own onBookmarked(), the app's callback alone decides what happens, just as it would replace Shiny's default. Counting callbacks reads a private field in both languages (private$bookmarkedCallbacks / _on_bookmarked_callbacks), since neither has a public way to count them.

This also applies to a page_react_html() document that loads Bootstrap itself, so those apps get the address-bar behavior instead of the modal too.

Checked by hand with the issue's R repro and a Python ReactApp(bookmark_store="url") app: clicking Bookmark updates the URL with no error.

@schloerke
schloerke added this pull request to stack #335 November 9, 2026 18:21
@schloerke
schloerke force-pushed the schloerke/bookmark-default branch from eb52611 to 3a669dd Compare November 9, 2026 21:41
… modal

Shiny's default onBookmarked action shows the URL in a Bootstrap modal, and
page_react() loads no Bootstrap, so session$doBookmark() / session.bookmark()
threw "$(...).modal is not a function". The shinyreact.init handler now
registers a default that calls updateQueryString() / update_query_string(),
and steps aside once the app registers its own callback.

Fixes #326
@schloerke
schloerke force-pushed the schloerke/bookmark-default branch from 3a669dd to fddbe22 Compare November 12, 2026 16:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default bookmark URL modal fails on page_react() pages ($(...).modal is not a function)

1 participant