Skip to content

Commit

Permalink
Merge branch 'main' into feature/bump_vizroai_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
lingyielia authored Feb 24, 2025
2 parents 2b0bcbb + 5d83703 commit d151441
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Changed
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Fixed
- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
19 changes: 11 additions & 8 deletions vizro-core/docs/pages/user-guides/custom-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,19 @@ Add the custom action `open_offcanvas` as a `function` argument inside the [`Act

### Trigger actions with a custom component

As mentioned above, custom components can trigger action. To enable the custom component to trigger the action, we need to add some extra code:
As mentioned above, custom components can trigger actions. To enable the custom component to trigger the action, add the `actions` field and specify which property triggers the actions:

1. **Add the `actions` argument to your custom component**. The type of the `actions` argument is `list[Action]`.
```py
actions: list[Action] = []
```
2. **Set the action through `_set_actions`**. In doing so, any change in the `"active_index"` property of the custom component triggers the action.
```py
_set_actions = _action_validator_factory("active_index")
```
2. **Set the action through `_action_validator_factory`**. In doing so, any change in the `"active_index"` property of the custom component triggers the action.

```py
actions: Annotated[
list[Action],
AfterValidator(_action_validator_factory("active_index")),
PlainSerializer(lambda x: x[0].actions),
Field(default=[]),
]
```


??? example "Example of triggering action with custom component"
Expand Down

0 comments on commit d151441

Please sign in to comment.