budibase
budibase copied to clipboard
Form Field `On Change` will not be emitted after the value changed by `Update Field Value` action
Hosting
- Self
- Method: docker compose
- Budibase Version: 1.1.4
Describe the bug
The On Change handler of form field component works well if the value has been changed by manual. but it will be not emitted
when we changed the value from some Update Filed Value action
To Reproduce Steps to reproduce the behavior: In any empty screen:
- Add a
Form - Add a
Text Fieldin the form - Add a
Update Stateaction to set any state inOn ChangeofText Field - Add a
Buttonin the from - Add a
Update Field Valuefor the buttom and udpate theText Fieldvalue to any other value. - Find the
Stateshould be updated bystep 3InDevTools
Expected behavior The value of state should be updated. But it is empty
Screenshots

Desktop (please complete the following information):
- OS: MacOS
- Browser: Chrome, Safari
Hey @taoyuan. This was a design decision, so I'm going to mark this as a feature request. I deliberately did not make "update field value" actions trigger other "on change" field handlers as I was worried about creating endless update loops, depending on how you had configured your settings. At the minute it explicitly only reacts to changes by the user.
If this is something you need and other people feel the same then we could look at adding this, but we would have to be careful so that people don't brick their apps by designing endless loops.
@aptkingston Got it. In addition, can we reference the same or other state value in the Update State action, for example,
State.itemshas been set as[{name: 'Tom'}]- Set
State.itemsto add some other items inUpdate Stateaction like:return [...$("State.items), {name: 'Jerry'}];
It seems that we can not retrieve any state value in Update State action.
@aptkingston Got it. In addition, can we reference the same or other state value in the
Update Stateaction, for example,1. `State.items` has been set as `[{name: 'Tom'}]` 2. Set `State.items` to add some other items in `Update State` action like: ```js return [...$("State.items), {name: 'Jerry'}]; ```It seems that we can not retrieve any state value in
Update Stateaction.
I'll have a look at this - it should be possible to do that.
@aptkingston After a deeper investigation, I found that the state value can be retreved by state.items. It's just the case of the first letter of the state. And the context to resolve the script is here: https://github.com/Budibase/budibase/blob/16dc6403e32a085e54435d246166f15df5d7202c/packages/client/src/utils/buttonActions.js#L362-L371
Was it designed this way? Or will it be changed in the future?
By the way, perhaps this project is the best looking and most promising low-code project of its kind I've found so far, it exceeds my expectations in some ways and it definitely qualifies as a great project.
@aptkingston After a deeper investigation, I found that the state value can be retreved by
state.items. It's just the case of the first letter of thestate. And thecontextto resolve the script is here:https://github.com/Budibase/budibase/blob/16dc6403e32a085e54435d246166f15df5d7202c/packages/client/src/utils/buttonActions.js#L362-L371
Was it designed this way? Or will it be changed in the future?
By the way, perhaps this project is the best looking and most promising low-code project of its kind I've found so far, it exceeds my expectations in some ways and it definitely qualifies as a great project.
Thanks for the extra info! If it works with lowercase state but not State, then it means the transformation must not be working. When you save bindings, we transform them from "readable" bindings into "runtime" bindings - which involves transforming component names into IDs and transforming other binding categories (like "State") into their runtime keys ("state" in this case). That particular JS binding must not be transforming correctly. That will save me some time while looking at this - thanks!
@aptkingston Glad to be able to help. 😄
This issue has been automatically marked as stale because it has not had recent activity.