diff --git a/packages/angular/src/lib/auth/forms/sign-in-auth-form.spec.ts b/packages/angular/src/lib/auth/forms/sign-in-auth-form.spec.ts index 742cd66a..e8fa2573 100644 --- a/packages/angular/src/lib/auth/forms/sign-in-auth-form.spec.ts +++ b/packages/angular/src/lib/auth/forms/sign-in-auth-form.spec.ts @@ -74,7 +74,7 @@ describe("", () => { }); expect(screen.getByLabelText("Email Address")).toBeInTheDocument(); - expect(screen.getByLabelText("Password")).toBeInTheDocument(); + expect(screen.getByLabelText("Password", { selector: "input" })).toBeInTheDocument(); expect(screen.getByRole("button", { name: "Sign In" })).toBeInTheDocument(); expect(screen.getByText("By continuing, you agree to our")).toBeInTheDocument(); expect(screen.getByRole("button", { name: "Forgot Password" })).toBeInTheDocument(); diff --git a/packages/angular/src/lib/auth/forms/sign-in-auth-form.ts b/packages/angular/src/lib/auth/forms/sign-in-auth-form.ts index a4570e1f..b2e6bb9e 100644 --- a/packages/angular/src/lib/auth/forms/sign-in-auth-form.ts +++ b/packages/angular/src/lib/auth/forms/sign-in-auth-form.ts @@ -61,7 +61,7 @@ import { type="password" > @if (forgotPassword) { - } diff --git a/packages/angular/src/lib/components/form.spec.ts b/packages/angular/src/lib/components/form.spec.ts index 3c1d60be..d7bf7fb2 100644 --- a/packages/angular/src/lib/components/form.spec.ts +++ b/packages/angular/src/lib/components/form.spec.ts @@ -16,8 +16,15 @@ import { render, screen } from "@testing-library/angular"; import { Component, signal } from "@angular/core"; - -import { FormMetadataComponent, FormActionComponent, FormSubmitComponent, FormErrorMessageComponent } from "./form"; +import { injectForm, TanStackAppField } from "@tanstack/angular-form"; + +import { + FormMetadataComponent, + FormActionComponent, + FormSubmitComponent, + FormErrorMessageComponent, + FormInputComponent, +} from "./form"; import { ButtonComponent } from "./button"; @Component({ @@ -164,6 +171,35 @@ describe("Form Components", () => { }); }); + describe("", () => { + @Component({ + template: ` + + + + `, + standalone: true, + imports: [FormInputComponent, TanStackAppField, FormActionComponent], + }) + class TestFormInputHostComponent { + form = injectForm({ + defaultValues: { + test: "", + }, + }); + } + + it("renders action content when provided", async () => { + await render(TestFormInputHostComponent, { + imports: [TestFormInputHostComponent], + }); + + const actionButton = screen.getByTestId("test-action"); + expect(actionButton).toBeTruthy(); + expect(actionButton).toHaveTextContent("Action"); + }); + }); + describe("", () => { it("renders error message when onSubmit error exists", async () => { await render(TestFormErrorMessageHostComponent); diff --git a/packages/angular/src/lib/components/form.ts b/packages/angular/src/lib/components/form.ts index 44c7d1e8..f332809d 100644 --- a/packages/angular/src/lib/components/form.ts +++ b/packages/angular/src/lib/components/form.ts @@ -30,16 +30,22 @@ export class FormMetadataComponent { imports: [FormMetadataComponent], template: ` diff --git a/packages/react/src/auth/forms/sign-in-auth-form.tsx b/packages/react/src/auth/forms/sign-in-auth-form.tsx index 17275b51..91be199a 100644 --- a/packages/react/src/auth/forms/sign-in-auth-form.tsx +++ b/packages/react/src/auth/forms/sign-in-auth-form.tsx @@ -95,13 +95,17 @@ export function SignInAuthForm({ onSignIn, onForgotPasswordClick, onSignUpClick
{(field) => ( - - {onForgotPasswordClick ? ( - - {getTranslation(ui, "labels", "forgotPassword")} - - ) : null} - + + {getTranslation(ui, "labels", "forgotPassword")} + + ) : null + } + /> )}
diff --git a/packages/react/src/components/form.test.tsx b/packages/react/src/components/form.test.tsx index 4a4a1f64..1568c34f 100644 --- a/packages/react/src/components/form.test.tsx +++ b/packages/react/src/components/form.test.tsx @@ -90,6 +90,36 @@ describe("form export", () => { expect(screen.getByTestId("test-child")).toBeInTheDocument(); }); + it("should render the Input action prop when provided", () => { + const { result } = renderHook(() => { + return form.useAppForm({ + defaultValues: { foo: "bar" }, + }); + }); + + const hook = result.current; + + render( + + + {(field) => ( + + Action + + } + /> + )} + + + ); + + expect(screen.getByTestId("test-action")).toBeInTheDocument(); + expect(screen.getByTestId("test-action")).toHaveTextContent("Action"); + }); + it("should render the Input metadata when available", async () => { const { result } = renderHook(() => { return form.useAppForm({ diff --git a/packages/react/src/components/form.tsx b/packages/react/src/components/form.tsx index ec83a5a8..8b67e67d 100644 --- a/packages/react/src/components/form.tsx +++ b/packages/react/src/components/form.tsx @@ -23,13 +23,17 @@ function Input({ children, before, label, + action, ...props -}: PropsWithChildren & { label: string; before?: ReactNode }>) { +}: PropsWithChildren & { label: string; before?: ReactNode; action?: ReactNode }>) { const field = useFieldContext(); return (