form-js
form-js copied to clipboard
Make it possible to listen to on focus events
Is your feature request related to a problem? Please describe
On Zeebe a user might have a variable of up to 4MB and because of that there might be cases on Zeebe Tasklist that a task has multiple big variables as initial values on the form which might cause the request to take too long to load or timeout. To solve that we want to load only a truncated value of each requested variable and only load the full value of the variable when the user focuses on the field
Describe the solution you'd like Create a new event that's dispatched when the user focuses on the field:
/**
* @type { (event: 'focus', callback: (state: { field: {name: string, type: 'textfield' | 'number' | ... } } ) => void) => void }
*/
form.on('focus', ({ field }) => {
// we can filter by field type so we don't fetch unnecessary variables, like boolean variables for example
if(field.type === 'textfield') {
request(field.name)
}
})
Context
The idea is to use this feature along with #39 and #67 to implement lazy loading of data.