Skip to content

docs: Explicitly call out module usage in bookmark button #1983

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

Merged
merged 6 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

* `selectize`, `remove_button`, and `options` parameters of `ui.input_select()` have been deprecated; use `ui.input_selectize()` instead. (Thanks, @ErdaradunGaztea!) (#1947)
* `selectize`, `remove_button`, and `options` parameters of `ui.input_select()` have been deprecated; use `ui.input_selectize()` instead. (Thanks, @ErdaradunGaztea!) (#1947)

* Improved the styling and readability of markdown tables rendered by `ui.Chat()` and `ui.MarkdownStream()`. (#1973)

### Bug fixes

* Explicitly call out module usage in UI input bookmark button documentation. (#1983)


## [1.4.0] - 2025-04-08

Expand Down
26 changes: 25 additions & 1 deletion shiny/bookmark/_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ def input_bookmark_button(

A `bookmarkButton` is a [input_action_button()] with a default label that consists of a link icon and the text "Bookmark...". It is meant to be used for bookmarking state.

Default behavior
----------------

By default, Shiny will listen for the default `id` being used and call
`session.bookmark()` on button click. However, this will not work if the bookmark
button is used within a module or more than one bookmark button is being utilized.

For both situations, a custom `id` value is required.

There are two recommendations to maintain the expected bookmark behavior:
* The supplied `id` value should be excluded from bookmarking with
`session.bookmark.exclude.append(ID)`.
* A reactive effect should be added that performs the bookmarking
(`session.bookmark()`) when the button is pressed.

```python
session.bookmark.exclude.append("CUSTOM_ID")

@reactive.effect
@reactive.event(input.CUSTOM_ID)
async def _():
await session.bookmark()
```

Parameters
----------
label
Expand All @@ -39,7 +63,7 @@ def input_bookmark_button(
disabled
Whether the button is disabled.
id
An ID for the bookmark button. The only time it is necessary to set the ID unless you have more than one bookmark button in your application. If you specify an input ID, it should be excluded from bookmarking with `session.bookmark.exclude.append(ID)`, and you must create a reactive effect that performs the bookmarking (`session.bookmark()`) when the button is pressed.
An ID for the bookmark button.
title
A tooltip that is shown when the mouse cursor hovers over the button.
kwargs
Expand Down
Loading