Skip to content

Commit 69c1ac3

Browse files
committed
Deprecate update_navs
1 parent 2ceaa36 commit 69c1ac3

File tree

16 files changed

+111
-19
lines changed

16 files changed

+111
-19
lines changed

examples/inputs-update/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _():
185185
# Tabset input =============================================
186186
# Change the selected tab.
187187
# The tabsetPanel must have been created with an 'id' argument
188-
ui.update_navs("inTabset", selected="panel2" if c_num % 2 else "panel1")
188+
ui.update_navset("inTabset", selected="panel2" if c_num % 2 else "panel1")
189189

190190

191191
app = App(app_ui, server, debug=True)

shiny/api-examples/navset_hidden/app-core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def server(input: Inputs, output: Outputs, session: Session):
1919
@reactive.effect
2020
@reactive.event(input.controller)
2121
def _():
22-
ui.update_navs("hidden_tabs", selected="panel" + str(input.controller()))
22+
ui.update_navset("hidden_tabs", selected="panel" + str(input.controller()))
2323

2424

2525
app = App(app_ui, server)

shiny/api-examples/navset_hidden/app-express.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
@reactive.effect
1717
@reactive.event(input.controller)
1818
def _():
19-
ui.update_navs("hidden_tabs", selected="panel" + str(input.controller()))
19+
ui.update_navset("hidden_tabs", selected="panel" + str(input.controller()))
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from shiny import App, Inputs, Outputs, Session, reactive, ui
2+
3+
app_ui = ui.page_sidebar(
4+
ui.sidebar(ui.input_slider("controller", "Controller", min=1, max=3, value=1)),
5+
ui.navset_card_tab(
6+
ui.nav_panel("Panel 1", "Panel 1 content", value="panel1"),
7+
ui.nav_panel("Panel 2", "Panel 2 content", value="panel2"),
8+
ui.nav_panel("Panel 3", "Panel 3 content", value="panel3"),
9+
id="inTabset",
10+
),
11+
)
12+
13+
14+
def server(input: Inputs, output: Outputs, session: Session):
15+
@reactive.effect
16+
def _():
17+
ui.update_navset("inTabset", selected="panel" + str(input.controller()))
18+
19+
20+
app = App(app_ui, server)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from shiny import reactive
2+
from shiny.express import input, ui
3+
4+
with ui.sidebar():
5+
ui.input_slider("controller", "Controller", min=1, max=3, value=1)
6+
7+
with ui.navset_card_tab(id="inTabset"):
8+
with ui.nav_panel("Panel 1", value="panel1"):
9+
"Panel 1 content"
10+
with ui.nav_panel("Panel 2", value="panel2"):
11+
"Panel 2 content"
12+
with ui.nav_panel("Panel 3", value="panel3"):
13+
"Panel 3 content"
14+
15+
16+
@reactive.effect
17+
def _():
18+
ui.update_navset("inTabset", selected="panel" + str(input.controller()))

shiny/express/ui/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
update_date_range,
9595
update_nav_panel,
9696
update_navs,
97+
update_navset,
9798
update_numeric,
9899
update_popover,
99100
update_radio_buttons,
@@ -246,6 +247,7 @@
246247
"update_text",
247248
"update_text_area",
248249
"update_navs",
250+
"update_navset",
249251
"update_tooltip",
250252
"update_popover",
251253
"insert_ui",

shiny/express/ui/_cm_components.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ def nav_panel(
12031203
value
12041204
The value of the item. This is used to determine whether the item is active
12051205
(when an ``id`` is provided to the nav container), programmatically select the
1206-
item (e.g., :func:`~shiny.ui.update_navs`), and/or be provided to the
1206+
item (e.g., :func:`~shiny.ui.update_navset`), and/or be provided to the
12071207
``selected`` argument of the navigation container (e.g.,
12081208
:func:`~shiny.ui.navset_tab`).
12091209
icon
@@ -1249,7 +1249,7 @@ def nav_menu(
12491249
value
12501250
The value of the item. This is used to determine whether the item is active
12511251
(when an ``id`` is provided to the nav container), programmatically select the
1252-
item (e.g., :func:`~shiny.ui.update_navs`), and/or be provided to the
1252+
item (e.g., :func:`~shiny.ui.update_navset`), and/or be provided to the
12531253
``selected`` argument of the navigation container (e.g.,
12541254
:func:`~shiny.ui.navset_tab`).
12551255
icon

shiny/express/ui/_insert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def insert_nav_panel(
111111
value
112112
The value of the panel. Use this value to determine whether the panel is active
113113
(when an `id` is provided to the nav container) or to programmatically
114-
select the item (e.g., :func:`~shiny.ui.update_navs`). You can also
114+
select the item (e.g., :func:`~shiny.ui.update_navset`). You can also
115115
provide the value to the `selected` argument of the navigation container
116116
(e.g., :func:`~shiny.ui.navset_tab`).
117117
icon

shiny/ui/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
update_date,
9595
update_date_range,
9696
update_navs,
97+
update_navset,
9798
update_numeric,
9899
update_popover,
99100
update_radio_buttons,
@@ -273,6 +274,7 @@
273274
"update_text",
274275
"update_text_area",
275276
"update_navs",
277+
"update_navset",
276278
"update_tooltip",
277279
"update_popover",
278280
# _insert

shiny/ui/_input_update.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"update_text",
1717
"update_text_area",
1818
"update_navs",
19+
"update_navset",
1920
)
2021

2122
import json
@@ -27,6 +28,7 @@
2728
from starlette.requests import Request
2829
from starlette.responses import JSONResponse, Response
2930

31+
from .._deprecated import warn_deprecated
3032
from .._docstring import add_example, doc_format, no_example
3133
from .._typing_extensions import NotRequired, TypedDict
3234
from .._utils import drop_none
@@ -1054,6 +1056,45 @@ def update_navs(
10541056
----
10551057
{note}
10561058
1059+
See Also
1060+
--------
1061+
* :func:`~shiny.ui.navset_tab`
1062+
* :func:`~shiny.ui.navset_pill`
1063+
* :func:`~shiny.ui.page_navbar`
1064+
"""
1065+
warn_deprecated(
1066+
"`shiny.ui.update_navs()` has been superseded by `shiny.ui.update_navset()` and will be removed in the near future."
1067+
)
1068+
1069+
update_navset(
1070+
id=id,
1071+
selected=selected,
1072+
session=session,
1073+
)
1074+
1075+
1076+
@add_example()
1077+
@doc_format(note=_note)
1078+
def update_navset(
1079+
id: str, selected: Optional[str] = None, session: Optional[Session] = None
1080+
) -> None:
1081+
"""
1082+
Change the value of a navs container on the client.
1083+
1084+
Parameters
1085+
----------
1086+
id
1087+
An input id.
1088+
selected
1089+
The values that should be initially selected, if any.
1090+
session
1091+
A :class:`~shiny.Session` instance. If not provided, it is inferred via
1092+
:func:`~shiny.session.get_current_session`.
1093+
1094+
Note
1095+
----
1096+
{note}
1097+
10571098
See Also
10581099
--------
10591100
* :func:`~shiny.ui.navset_tab`

0 commit comments

Comments
 (0)