Collecting use cases for async conditional fields
See original GitHub issueIn case you didn’t see it, we’ve released conditional fields!
…however, the current implementation does not support an async hidden
calback. This issue exists to collect use cases for async conditional fields so we can provide an alternative mechanism.
Context: why are async conditional fields difficult to implement?
There are a few challenges with making this API async:
-
Layout critical — This feature has more implications than similar ones (e.g. custom validation) because the layout of the form is dependent on the results of your
hidden
callback. We want to ensure consistency between the form fields shown and the logic in yourhidden
callbacks. If we were to naively allow async, we could easily get into situations where multiple mutually exclusive fields are shown at the same time.
This contrasts with the validation API (which does allow async). With the validation API, it’s much easier to defer and debounce validation results because the layout is not dependent on validation and we can disable the Publish button until all validation has finished running. -
Reactivity — Sometimes is async is not enough. If you’re pulling a value asynchronously, you’d probably also like to make this hidden logic re-run when that value changes.
-
How often the function will be called — Because the condition function takes in the document as an argument, and because we want immediate consistency, it will be called every time the document is updated. You may want to call an API to get a result and this may result in many networks requests.
TL;DR let’s come up with something else!
What are your use cases for async conditional fields?
This issue is to track use cases for conditional fields to see if we can come up with something else that preserves the current simplicity and performance while still doing the job of async conditional fields.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Wondering for this use case: A document has 2 fields:
type
type
My use case is similar to to 3200pros.
We have a configuration type. I’d love to to hide fields based on what the user set in that configuration type. It’s not referenced directly, so I would have used a groq query if async was possible.