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

FormKitSchema missing to set instanceScopes when schema changed #610

Closed
haan123 opened this issue Mar 10, 2023 · 6 comments
Closed

FormKitSchema missing to set instanceScopes when schema changed #610

haan123 opened this issue Mar 10, 2023 · 6 comments
Labels
🐛 bug Verified bug by team 🔵 priority-3 3. Lower priority issue 🚀 release-ready Feature or fix is complete and on an upcoming release branch
Milestone

Comments

@haan123
Copy link

haan123 commented Mar 10, 2023

Reproduction

https://formkit.link/26044964938a01897a2ff6355c180b53

Describe the bug

I have a plugin to translate the labels and placeholders, but when the schema is updated, it was not called then the labels and placeholders are empty, refer to the reproduction link for details.

I investigated in the packages/vue/src/FormKitSchema.ts, you are watching the props.schema, but in the watching's handler, you don't set the instanceScopes to the new instanceKey

image

Please check it to see if it's a bug, if it is, I can create a PR to fix this issue if needed.

Thanks!

Environment

• OS: Mac OS
• Browser chrome
• Version 1.0.0-beta.15

@haan123 haan123 added ⛑ Needs triage The issue has not yet been examined by the FormKit team. 🐛 bug-report Bug is reported, but not verified by team labels Mar 10, 2023
@haan123
Copy link
Author

haan123 commented Mar 11, 2023

@justin-schroeder sorry to bother you but this is quite urgent for my project, could you take a look at this issue?
Do we have any workaround in the meantime?
Thank you!

@justin-schroeder
Copy link
Member

Perhaps there is a bug here, will need further investigation — however, you really shouldn't need to modify the schema hardly ever. That watcher is in there as a concession that for some applications it may be useful to modify the schema, but you do take a pretty sizable performance hit to do so. As a workaround consider iterating over data and pushing onto that data instead.

@haan123
Copy link
Author

haan123 commented Mar 12, 2023

@justin-schroeder how to deal with a dynamic schema like adding more fields to a group? E.g:

// Add this field to the form in runtime
{
  $cmp: "CustomField",
  props: {
	name: "test",
	type: "CCustomCheckbox",
	label: "test",
  },
}

@fenilli
Copy link
Contributor

fenilli commented Mar 12, 2023

Have a component that gets fields as an array that will render your fields at runtime, so your schema won't get changed.

@haan123
Copy link
Author

haan123 commented Mar 13, 2023

@GustavoFenilli thanks for your suggestion!

Could you provide some sample code?

Sure, we can loop through the fields if the schema is simple with 1 level, but if it has nested group or list, how to render the nested schema, and how do we handle the add new group to the nested list or new field to the nested group?

Recently, this is my main concern about the schema approach of this library

Thanks!

@quanghm27
Copy link

@haan123

  • for add/remove an input in runtime, did you try to add if property?
// Add this field to the form in runtime
{
  $cmp: "CustomField",
  props: {
	name: "test",
	type: "CCustomCheckbox",
	label: "test",
	if: "true",
  },
}
  • for nested value, we can use dot notation get('nodeName.someProp.someProp').

@justin-schroeder justin-schroeder added 🔬 research required The FormKit team is looking into this and removed 🐛 bug-report Bug is reported, but not verified by team ⛑ Needs triage The issue has not yet been examined by the FormKit team. labels Mar 23, 2023
@justin-schroeder justin-schroeder added this to the Stability milestone Mar 23, 2023
@justin-schroeder justin-schroeder added 🔵 priority-3 3. Lower priority issue 🐛 bug Verified bug by team 🚀 release-ready Feature or fix is complete and on an upcoming release branch and removed 🔬 research required The FormKit team is looking into this labels Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Verified bug by team 🔵 priority-3 3. Lower priority issue 🚀 release-ready Feature or fix is complete and on an upcoming release branch
Projects
None yet
Development

No branches or pull requests

4 participants