Skip to content
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

The ability to use dyanmicFields in children fields. #479

Open
jase-languasco opened this issue Jan 28, 2022 · 11 comments
Open

The ability to use dyanmicFields in children fields. #479

jase-languasco opened this issue Jan 28, 2022 · 11 comments

Comments

@jase-languasco
Copy link

Current Behavior

I received this error: inputField keys must be unique for each action, even if they're children. The key "undefined" is already in use at creates.x.operation.inputFields[5].children[2].key

Desired Behavior

{
    key: 'field',
    label: 'Field', 
    children: [
        (z, bundle) => myChildDynamicField(z, bundle),
    ],
}
@xavdid
Copy link
Contributor

xavdid commented Jan 28, 2022

ah, that's a bug! I can fix it.

You'll still want to make sure the fields returned by myChildDynamicField have unique keys, but the static checker won't flag them for you.

Thanks for reporting!

@xavdid xavdid added the bug Something isn't working label Jan 28, 2022
@zapzap
Copy link
Collaborator

zapzap commented Jan 28, 2022

This issue has been copied into our private issue tracker (as PDE-3003). Thanks for the report! We'll update this as we learn more.

@jase-languasco
Copy link
Author

The same function I'm using on the child field is being used on another action as a primary inputField and it's working fine.

@jase-languasco
Copy link
Author

@zapzap @xavdid how long can I expect to wait for a patch? I'm trying to decide if I need to figure out a work around or if I can wait on this.

@xavdid
Copy link
Contributor

xavdid commented Jan 28, 2022

You can reuse the function, you just want to avoid this:

fields: [
  { key: 'name' },
  children: [
    () => { key: 'name' }
  ]
]

Though, now that I look, I think I've fixed this issue before. What version of zapier-platform-core does your app depend on?

@jase-languasco
Copy link
Author

image

@xavdid
Copy link
Contributor

xavdid commented Jan 28, 2022

Ah ok, I realized what's going on.

The actual issue is that the children field, by definition, can't have dynamic fields. The schema specifies that it only allows field objects.

The functional validator that checks for unique keys is throwing an error because it doesn't expect non-objects in children, which is obscuring the actual schema error. When I fixed the validator locally, it told me that creates.x.operation.inputFields[5] isn't valid because its children are of the wrong type.


So, there's two things here:

  1. The feature request to be able to use dynamic fields in children
  2. Getting you unblocked today

For 1 - we can file the request with our editor team. They'll know best whether that's possible or not.

For 2 - consider not using children if you can avoid it. Depending on your use case, there may be another way to get the same effect.

@xavdid xavdid added feature-request and removed bug Something isn't working labels Jan 28, 2022
@jase-languasco
Copy link
Author

@xavdid Thank you for the recommendation. This particular action has lots of fields so being able to group a subset with children was going to be a nice enhancement, but maybe another day! Thank you for your help!

@jase-languasco
Copy link
Author

Depending on your use case, there may be another way to get the same effect.

@xavdid Is there another way to group fields? I can't recall seeing anything in the documentation.

@xavdid
Copy link
Contributor

xavdid commented Jan 31, 2022

There's not another way to group fields at this time, but it's a common request. It's definitely on our radar! A lot of people reach for children, since it does provide some nice UI. But, it's also got implications for how the data is structured, so we don't always recommend it for that use.

@jase-languasco
Copy link
Author

Okay, thanks for letting me know. I look forward to what you all come up with. In this particular case, the UI and the data structure of children is ideal, so I hope that children can support dynamicFields at some point!

Thanks again for all your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants