ink-form icon indicating copy to clipboard operation
ink-form copied to clipboard

onChange for FormField isn't triggered

Open OriR opened this issue 2 years ago • 0 comments

Describe the bug When creating a FormField with an onChange handler, the handler isn't called, even though it's defined om the type.

To Reproduce Steps to reproduce the behavior:

<Form form={{ sections: [ { type: "boolean", title: "a", name: "a", label: "a", onChange: () => { throw new Error("never thrown"); }} ]}} />

Expected behavior I'd expect the onChange handler to be called.

Additional context I'm looking to conditionally render fields in a form as requested in #6 but I feel like having a custom manager for a built-in field just to get the onChange handler to work, feels too detailed for such a common task.

Plus, the onChange attribute is already part of the FormField definition so when working with typescript it tells you that it's already part of the API.

Anyway, thanks for this tool, was super easy to create a pretty cool form 🙏

P.S. if you could support ink@4 and react@18 that would also be amazing!

OriR avatar Mar 31 '23 22:03 OriR