-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
adds allow_optional
to State and Input to place no value as the placeholders
#3294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dash/dependencies.py
Outdated
): | ||
super().__init__(component_id, component_property) | ||
self.allow_optional = allow_optional | ||
self.allowed_wildcards = (MATCH, ALL, ALLSMALLER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a class attribute before, it doesn't change on the object and I mistyped the typing on L37 it should finish in = ()
to be a class attribute.
Searching for reference usage, there is none, I think it could actually be removed. The actual check happens on the frontend and they are defined here:
dash/dash/dash-renderer/src/actions/dependencies.js
Lines 56 to 60 in 3488bbe
const allowedWildcards = { | |
Output: {ALL, MATCH}, | |
Input: wildcards, | |
State: wildcards | |
}; |
dash/dependencies.py
Outdated
@@ -56,7 +58,8 @@ def component_id_str(self) -> str: | |||
return stringify_id(self.component_id) | |||
|
|||
def to_dict(self) -> dict: | |||
return {"id": self.component_id_str(), "property": self.component_property} | |||
specs = {"id": self.component_id_str(), "property": self.component_property} | |||
return {**specs, "allow_optional": True} if self.allow_optional else specs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda weird to read, should be:
if self.allow_optional:
specs["allow_optional"] = True
return specs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 Look good, just a minor code style comment.
Sometimes there is a need to have conditional inputs/states in callbacks, this allows this to happen by passing the conditions to the clientside to be parsed and null values passed back.
This is accessible by
allow_optional=True
on the Input/State.fixes: #3067