fix crash due to an invalid state of connected field that was deleted (#19421)

This commit is contained in:
Hariom Balhara
2025-02-21 11:32:51 +05:30
committed by GitHub
parent 0d2ec20f66
commit fbcfc35621
3 changed files with 8 additions and 2 deletions
@@ -1987,7 +1987,7 @@
"a_routing_form": "A Routing Form",
"form_description_placeholder": "Form Description",
"keep_me_connected_with_form": "Keep me connected with the form",
"fields_in_form_duplicated": "Any changes in Router and Fields of the form being duplicated, would reflect in the duplicate.",
"fields_in_form_duplicated": "Any changes made to the router or fields of the form being duplicated will be reflected in the duplicate. However, deleting a field will not remove it from the duplicate.",
"form_deleted": "Form deleted",
"delete_form": "Are you sure you want to delete this form?",
"delete_form_action": "Yes, delete Form",
@@ -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> {