Hi,
I am creating a smart action form and want to use the change hook for a field of type [“String”]. But the hook is never triggered on updates, only on the very first input. In other words, when I add the first element to the array, it triggers the hook, then never again afterward.
FYI, I tried changing the types of the field to “String” or “Number” and then the hook works as expected.
I am using forest-express-mongoose: v. 8.7.8
Feature(s) impacted
Observed behavior
The hook is only triggered 1 time when adding the first element to the array. After this, it is never triggered again, no matter how many elements I add/remove.
Smart action form:
{
name: "Test",
type: "global",
endpoint: "/forest/actions/test",
fields: [
{
field: "test",
type: ["String"],
isRequired: true,
defaultValue: [],
hook: "onTestChange",
},
],
hooks: {
change: {
onTestChange: async ({ fields, request, changedField }) => {
console.log("Hook triggered!");
return fields;
},
},
},
},
These are the only logs outputted (only once):
Hook triggered!
POST /forest/actions/test/hooks/change?timezone=Europe%2FStockholm 200 244 - 3.584 ms
Expected behavior
Each time an element is added/removed, I expect the change hook to be triggered.
Context
Project: PayAtt Internal Admin Portal
Team: IT
Environment: Development