From abf149df9cf764137f787d2478729c707dc83f21 Mon Sep 17 00:00:00 2001 From: Maximilian Schulz Date: Fri, 29 Nov 2024 11:42:24 +0000 Subject: [PATCH] Add _input_property to private form models to make them work in controls --- vizro-core/src/vizro/models/_components/form/_text_area.py | 7 +++++-- .../src/vizro/models/_components/form/_user_input.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/vizro-core/src/vizro/models/_components/form/_text_area.py b/vizro-core/src/vizro/models/_components/form/_text_area.py index 5ac25fdb7..bb1ea7fa1 100644 --- a/vizro-core/src/vizro/models/_components/form/_text_area.py +++ b/vizro-core/src/vizro/models/_components/form/_text_area.py @@ -4,9 +4,9 @@ from dash import html try: - from pydantic.v1 import Field + from pydantic.v1 import Field, PrivateAttr except ImportError: # pragma: no cov - from pydantic import Field + from pydantic import Field, PrivateAttr from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory @@ -32,6 +32,9 @@ class TextArea(VizroBaseModel): placeholder: str = Field("", description="Default text to display in input field") actions: list[Action] = [] + # Component properties for actions and interactions + _input_property: str = PrivateAttr("value") + # Re-used validators # TODO: Before making public, consider how actions should be triggered and what the default property should be # See comment thread: https://github.com/mckinsey/vizro/pull/298#discussion_r1478137654 diff --git a/vizro-core/src/vizro/models/_components/form/_user_input.py b/vizro-core/src/vizro/models/_components/form/_user_input.py index bb98a14bb..7ca821f65 100644 --- a/vizro-core/src/vizro/models/_components/form/_user_input.py +++ b/vizro-core/src/vizro/models/_components/form/_user_input.py @@ -4,9 +4,9 @@ from dash import html try: - from pydantic.v1 import Field + from pydantic.v1 import Field, PrivateAttr except ImportError: # pragma: no cov - from pydantic import Field + from pydantic import Field, PrivateAttr from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory @@ -32,6 +32,9 @@ class UserInput(VizroBaseModel): placeholder: str = Field("", description="Default text to display in input field") actions: list[Action] = [] + # Component properties for actions and interactions + _input_property: str = PrivateAttr("value") + # Re-used validators # TODO: Before making public, consider how actions should be triggered and what the default property should be # See comment thread: https://github.com/mckinsey/vizro/pull/298#discussion_r1478137654