33import warnings
44from abc import ABC , abstractmethod
55from pathlib import Path
6- from typing import TYPE_CHECKING , Awaitable , Callable , Literal
6+ from typing import TYPE_CHECKING , Awaitable , Callable , Literal , Optional
77
88from .._docstring import add_example
99from .._utils import AsyncCallbacks , CancelCallback , wrap_async
@@ -167,7 +167,7 @@ def on_restored(
167167 @abstractmethod
168168 async def update_query_string (
169169 self ,
170- query_string : str ,
170+ query_string : Optional [ str ] = None ,
171171 mode : Literal ["replace" , "push" ] = "replace" ,
172172 ) -> None :
173173 """
@@ -176,7 +176,7 @@ async def update_query_string(
176176 Parameters
177177 ----------
178178 query_string
179- The query string to set.
179+ The query string to set. If `None`, the current bookmark state URL will be used.
180180 mode
181181 Whether to replace the current URL or push a new one. Pushing a new value
182182 will add to the user's browser history.
@@ -448,9 +448,12 @@ async def invoke_on_restored_callbacks():
448448
449449 async def update_query_string (
450450 self ,
451- query_string : str ,
451+ query_string : Optional [ str ] = None ,
452452 mode : Literal ["replace" , "push" ] = "replace" ,
453453 ) -> None :
454+ if query_string is None :
455+ query_string = await self .get_bookmark_url ()
456+
454457 if mode not in {"replace" , "push" }:
455458 raise ValueError (f"Invalid mode: { mode } " )
456459 await self ._root_session ._send_message (
0 commit comments