Action field values after onChange hook

Expected behavior

Not sure if this is a bug or feature :slight_smile:
I set the onChange hook and don’t set the load hook. I trigger the onChange hook on the UI (setting a new enum for a field) and then close the action form. Then I open it again (for any record including the same one). The form has initial values as described in the action itself (an empty enum).

Actual behavior

The form has some values that were set in the onChange hook for the previous record.


  • Package Version: 8.3.0
  • Express Version: 4.17.1
  • Sequelize Version: 5.22.4
  • Database Dialect: mysql
  • Database Version: 5

Hey @Tatsyana_Slabodchyka,

From what I understand, this is indeed a feature :slight_smile:

Smart action forms are completely reset once the form is close & re-open.
To add default values on form open, I would suggest to add a load hook instead.

However, I would be happy to understand your use case, or why did you expect the onChange enum value to be maintained on form close & open. We spec’d it this way, but we may have missed some specific use cases :slight_smile:

Let me know

No-no, this is the issue - form is no reset, I see previous values. If I add a load hook - the form is cleaned, yes, but without it - it keeps its values

No, my bad, I misread the Expected/Actual title :sweat_smile:
If you experience this, this is indeed a bug - As stated previously, the form should be reset each time it is open.

Could you share the implementation of your smart hook here (Or as a DM if you consider it private?)


    name: 'Action',
    endpoint: '/endpoint',
    type: 'single',
    fields: [
        field: 'reason',
        type: 'Enum',
        enums: ['any', 'value'],
        isRequired: true,
        hook: 'onReasonChanged',
        field: 'email',
        type: 'Enum',
        enums: [],
        isRequired: false,
    hooks: {
      change: {
        onReasonChanged: async ({ fields }) => {
          const reasonField = fields.find((field) => field.field === 'email');

          reasonField.enums = ['', ''];
          reasonField.value = '';

          return fields;

So after I chose any reason I always see the email enum though initially it was empty

Indeed, I’m totally able to reproduce the issue.
I’ll open a bug report on our end, and we will update the thread once this is fixed.

Thanks for the report :pray:

1 Like