As the title states, I'm trying to use the afterChange hook in a group field (with a nested row) to unset a child field if a sibling is unset (so essentially both become null). But this doesn't work:
{
name: "basePackage",
type: "group",
fields: [
{
type: "row",
fields: [
{
name: "basePackage",
type: "relationship",
relationTo: "health-insurance-packages",
},
{
name: "premium",
type: "number",
admin: {
condition: (_, siblingData) =>
siblingData.basePackage != null,
},
},
],
},
],
hooks: {
afterChange: [
({ value }) => {
if (value?.basePackage != null) return value;
return { basePackage: null, premium: null };
},
] satisfies FieldHook<
IHealthInsuranceComparison & { id: string },
NonNullable<
IHealthInsuranceComparison["combinations"]
>[number]["basePackage"]
>[],
},
},```
Is this a limitation due to the nested usage of `group` and `row` or am I doing something wrong to trigger an unset?