adds allow_optional to State and Input to place no value as the placeholders#3294
Merged
Conversation
T4rk1n
reviewed
May 1, 2025
| ): | ||
| super().__init__(component_id, component_property) | ||
| self.allow_optional = allow_optional | ||
| self.allowed_wildcards = (MATCH, ALL, ALLSMALLER) |
Contributor
There was a problem hiding this comment.
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
T4rk1n
reviewed
May 5, 2025
| 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 |
Contributor
There was a problem hiding this comment.
This is kinda weird to read, should be:
if self.allow_optional:
specs["allow_optional"] = True
return specs
T4rk1n
approved these changes
May 5, 2025
T4rk1n
left a comment
Contributor
There was a problem hiding this comment.
💃 Look good, just a minor code style comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=Trueon the Input/State.fixes: #3067