Skip to content

Commit

Permalink
add keep-alive to ui.stepper (fixes #1638)
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Sep 18, 2023
1 parent ff39f3a commit 86181c7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nicegui/elements/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@ class Stepper(ValueElement):
def __init__(self, *,
value: Union[str, Step, None] = None,
on_value_change: Optional[Callable[..., Any]] = None,
keep_alive: bool = True,
) -> None:
"""Stepper
This element represents `Quasar's QStepper <https://quasar.dev/vue-components/stepper#qstepper-api>`_ component.
It contains individual steps.
To avoid issues with dynamic elements when switching steps,
this element uses Vue's `keep-alive <https://vuejs.org/guide/built-ins/keep-alive.html>`_ component.
If client-side performance is an issue, you can disable this feature.
:param value: `ui.step` or name of the step to be initially selected (default: `None` meaning the first step)
:param on_value_change: callback to be executed when the selected step changes
:param keep_alive: whether to use Vue's keep-alive component on the content (default: `True`)
"""
super().__init__(tag='q-stepper', value=value, on_value_change=on_value_change)
self._props['keep-alive'] = keep_alive

def _value_to_model_value(self, value: Any) -> Any:
return value._props['name'] if isinstance(value, Step) else value # pylint: disable=protected-access
Expand Down

0 comments on commit 86181c7

Please sign in to comment.