Frontmatter
| id | 4818 |
| title | form.field.Checkbox, form.field.Text: Fire userChange event |
| state | Closed |
| labels | enhancement |
| assignees | tobiu |
| createdAt | Sep 1, 2023, 4:33 PM |
| updatedAt | Dec 5, 2023, 1:12 PM |
| githubUrl | https://github.com/neomjs/neo/issues/4818 |
| author | pensuwan-k |
| commentsCount | 12 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 5, 2023, 1:12 PM |
form.field.Checkbox, form.field.Text: Fire userChange event

@tobiu I tried to implement userchange event in Checkbox component's onInputValueChange method:
But this method also gets triggered when the checkbox value is changed programmatically (e.g. bind). Is there any other way to differentiate user triggered change?

you are right: a programmatic change will trigger onInputValueChange () too, since it will update the DOM afterwards.
however: inside the method => if checked === me.checked it should be a programmatic change (since the value already updated before the DOM change) and vise versa. just thinking out loud, needs some testing :)

Just tested the solution:
checked has always the opposite value of me.checked, so the condition is never true.

@ThorstenRaab

@dztoprak: just did a quick test. the first 2 changes happened when clicking on the field. opposite value for this one.
when programmatically changing the checked state, onInputValueChange() does not trigger at all for me. so we could just always fire a custom event in there. needs testing :)

looks the same way for TextFields:

For me, the onInputValueChange is triggered by all programmatic changes in checkboxes. I haven't tried with the text fields though:
https://github.com/neomjs/neo/assets/126246513/902d9a2b-dd98-41f0-a8fa-a5ebedadf3c7

careful deniz: IF you are clicking on one checkbox to change the checked state of a different one, you will get onInputValueChanged() for the one you clicked on :)
try what i did => control + right click on a checkbox. store it inside a global var. then change the checked state inside the dev tools.

good point, checkbox controllers are not exempt from the checkbox logic of course 😄

@tobiu do you know how can I access the oldValue in Text's onInputValueChange method?

sure. before setting this.value, you can access this.value or this._value to get the old value :)

resolved already.
It would be good to make a distinction between change events that are triggered programmatically or by user input