Smart action field hook not triggering for array type

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

Using a smart action form

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

Hello @zakarias ,

Thank you for your feedback, it is very important for us to have this information. Indeed I manage on my side to reproduce your problem, I have just added the resolution of this bug to the list of our tasks and we start to work on it. :pray:

Kind regards,

Florian

2 Likes

Hello @Florian_Gonzales,

Thank you for your response. Sounds good, I’ll be waiting eagerly for a solution :slight_smile:

Kind regards,
Zakarias

1 Like

Hello @zakarias ,

The bug fix for your problem is normally live! The change hook trigger in the smart action should work correctly now, sorry for the wait. Please tell me if your problem is now well solved :pray:

Kind regards,

Florian

Hi @Florian_Gonzales,

I’m sorry for the slow response, I was away for a week.

Unfortunately, I am still seeing the problem. I upgraded to use forest-express-mongoose@8.7.9.

Kind regards,
Zakarias

Hello @zakarias ,

Sorry for the inconvenience we had problems on the component related to this feature recently. A fix for the problem will be released on Monday, I will send you back at that time and your problem should be solved then !

Kind regards,

Florian

1 Like

Hello @zakarias ,

We have deployed a patch that is supposed to solve your problem. If you could tell me if everything is working properly for you it would be great! :pray:

Kind regards,

Florian

Hello @Florian_Gonzales,

Everything works perfectly again. Thank you!

Kind regards,
Zakarias

1 Like