Groups error when changing to a doc with non-existing field group #3794
-
Hey, I am facing an issue with the latest version (dev-preview.22). [edit] Actually the problem happens with older version as well. When I go to an another document that has different group fields. Changing to a document that does not have the same group field selected will throw an error. You can see this in action here: https://www.loom.com/share/b2c51ced26c14944892cb19c8bb672e2 [edit] I didn't know we could embed videos and images here. I added the issue in action here: Enregistrement.de.l.ecran.2022-10-28.a.10.23.49.mov |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I actually found a way to fix this, but I do not know how to contribute to v3. The fix is in this file: What is the right way to contribute to v3? // ...
function prepareObjectInputState<T>(
props: RawState<ObjectSchemaType, T>,
enableHiddenCheck = true
): ObjectFormNode | null {
// ...
const defaultGroupName = (schemaTypeGroupConfig.find((g) => g.default) || ALL_FIELDS_GROUP)?.name
// add this:
const schemaTypeGroups = [ALL_FIELDS_GROUP, ...schemaTypeGroupConfig];
const fieldGroupStateName = schemaTypeGroups.find((g) => g.name == props.fieldGroupState?.value)?.name;
// then:
const groups = schemaTypeGroups.flatMap((group): FormFieldGroup[] => {
// ...
// change: const isSelected = group.name === (props.fieldGroupState?.value || defaultGroupName)
// to:
const isSelected = group.name === (fieldGroupStateName || defaultGroupName)
// ...
})
} This code keeps the group selection active between doc change. And if the group field does not exist, it selects the default group or All fields. |
Beta Was this translation helpful? Give feedback.
-
This should be addressed by #4050 which is scheduled for release in the next couple of days. Thank you for an excellent description of the issue! |
Beta Was this translation helpful? Give feedback.
This should be addressed by #4050 which is scheduled for release in the next couple of days. Thank you for an excellent description of the issue!