From e751896e6d97c33c12ad87ec5c7fb052b051730e Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Sat, 25 Mar 2023 09:51:00 +0000 Subject: [PATCH] feat: pass the changed attribute though the onChange form callback Ref: #143 --- src/form.tsx | 4 ++-- tests/on-change.spec.tsx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/form.tsx b/src/form.tsx index 88ac851..53080a1 100644 --- a/src/form.tsx +++ b/src/form.tsx @@ -61,7 +61,7 @@ export interface FormProps { /** * Callback that is called whenever an attribute is changed */ - onChange?: (context: ReturnType["getContextValue"]>) => void; + onChange?: (context: ReturnType["getContextValue"]>, attribute: string) => void; /** * * TODO(ade): sort out prop with children @@ -193,7 +193,7 @@ export class Form> extends React.Component { }); expect(onChange).toHaveBeenCalled(); + expect(onChange).toBeCalledWith(expect.objectContaining({ formState: { "test-input": "A" } }), "test-input"); });