fix crash due to an invalid state of connected field that was deleted (#19421)
This commit is contained in:
1 parent
0d2ec20f66
commit
fbcfc35621
3 files changed
+8
-2
No files matched your search
@@ -37,7 +37,10 @@ export default function FormInputFields(props: FormInputFieldsProps) {
|
||||
{form.fields?.map((field) => {
|
||||
if (isRouterLinkedField(field)) {
|
||||
// @ts-expect-error FIXME @hariombalhara
|
||||
field = field.routerField;
|
||||
const routerField = field.routerField;
|
||||
// A field that has been deleted from the main form would still be there in the duplicate form but disconnected
|
||||
// In that case, it could mistakenly be categorized as RouterLinkedField, so if routerField is nullish, we use the field itself
|
||||
field = routerField ?? field;
|
||||
}
|
||||
const widget = formFieldsQueryBuilderConfig.widgets[field.type];
|
||||
if (!("factory" in widget)) {
|
||||
|
||||
@@ -2,6 +2,9 @@ import type { z } from "zod";
|
||||
|
||||
import type { zodFieldView, zodField, zodRouterField, zodRouterFieldView } from "../zod";
|
||||
|
||||
/**
|
||||
* It has been seen that the field had routerId but not routerField, which could be considered an invalid state. We need to analyze why rotuerId is still set in that case and infact should have been cleanedup.
|
||||
*/
|
||||
export default function isRouterLinkedField(
|
||||
field: z.infer<typeof zodFieldView> | z.infer<typeof zodField>
|
||||
): field is z.infer<typeof zodRouterField> | z.infer<typeof zodRouterFieldView> {
|
||||
|
||||
Reference in new issue
Block a user