Skip to content

Commit ad60445

Browse files
authored
Merge pull request #1234 from firebase/@invertase/bb-17
2 parents 452b7be + 5795b42 commit ad60445

File tree

6 files changed

+30
-10
lines changed

6 files changed

+30
-10
lines changed

packages/angular/src/lib/auth/forms/sign-in-auth-form.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ import {
5353
></fui-form-input>
5454
</fieldset>
5555
<fieldset>
56-
<fui-form-input name="password" tanstack-app-field [tanstackField]="form" label="{{ passwordLabel() }}">
56+
<fui-form-input
57+
name="password"
58+
tanstack-app-field
59+
[tanstackField]="form"
60+
label="{{ passwordLabel() }}"
61+
type="password"
62+
>
5763
@if (forgotPassword) {
5864
<button fui-form-action (click)="forgotPassword.emit()">
5965
{{ forgotPasswordLabel() }}

packages/angular/src/lib/auth/forms/sign-up-auth-form.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ import {
5757
<fui-form-input name="email" tanstack-app-field [tanstackField]="form" label="{{ emailLabel() }}" />
5858
</fieldset>
5959
<fieldset>
60-
<fui-form-input name="password" tanstack-app-field [tanstackField]="form" label="{{ passwordLabel() }}" />
60+
<fui-form-input
61+
name="password"
62+
tanstack-app-field
63+
[tanstackField]="form"
64+
label="{{ passwordLabel() }}"
65+
type="password"
66+
/>
6167
</fieldset>
6268
<fui-policies />
6369
<fieldset>

packages/angular/src/lib/components/form.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class FormMetadataComponent {
3333
<span>{{ label() }}</span>
3434
<input
3535
[attr.aria-invalid]="field.api.state.meta.isTouched && field.api.state.meta.errors.length > 0"
36+
[type]="type()"
3637
[id]="field.api.name"
3738
[name]="field.api.name"
3839
[value]="field.api.state.value"
@@ -47,6 +48,7 @@ export class FormMetadataComponent {
4748
export class FormInputComponent {
4849
field = injectField<string>();
4950
label = input.required<string>();
51+
type = input<string>("text");
5052
}
5153

5254
@Component({

packages/react/src/auth/forms/sign-in-auth-form.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ describe("<SignInAuthForm />", () => {
193193

194194
// Make sure we have an email and password input
195195
expect(screen.getByRole("textbox", { name: /email/i })).toBeInTheDocument();
196-
expect(screen.getByRole("textbox", { name: /password/i })).toBeInTheDocument();
196+
expect(screen.getByLabelText(/password/i)).toBeInTheDocument();
197197

198198
// Ensure the "Sign In" button is present and is a submit button
199199
const signInButton = screen.getByRole("button", { name: "signIn" });

packages/react/src/auth/forms/sign-up-auth-form.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ describe("<SignUpAuthForm />", () => {
274274

275275
// Make sure we have an email and password input with translated labels
276276
expect(screen.getByRole("textbox", { name: /emailAddress/ })).toBeInTheDocument();
277-
expect(screen.getByRole("textbox", { name: /password/ })).toBeInTheDocument();
277+
expect(screen.getByLabelText(/password/)).toBeInTheDocument();
278278

279279
// Ensure the "Create Account" button is present and is a submit button
280280
const createAccountButton = screen.getByRole("button", { name: "createAccount" });
@@ -365,7 +365,7 @@ describe("<SignUpAuthForm />", () => {
365365

366366
// Make sure we have all three inputs with translated labels
367367
expect(screen.getByRole("textbox", { name: /emailAddress/ })).toBeInTheDocument();
368-
expect(screen.getByRole("textbox", { name: /password/ })).toBeInTheDocument();
368+
expect(screen.getByLabelText(/password/)).toBeInTheDocument();
369369
expect(screen.getByRole("textbox", { name: /displayName/ })).toBeInTheDocument();
370370

371371
// Ensure the "Create Account" button is present and is a submit button
@@ -397,7 +397,7 @@ describe("<SignUpAuthForm />", () => {
397397
expect(form.length).toBe(1);
398398

399399
expect(screen.getByRole("textbox", { name: /email/ })).toBeInTheDocument();
400-
expect(screen.getByRole("textbox", { name: /password/ })).toBeInTheDocument();
400+
expect(screen.getByLabelText(/password/)).toBeInTheDocument();
401401
expect(screen.queryByRole("textbox", { name: /displayName/ })).not.toBeInTheDocument();
402402
});
403403

packages/react/src/components/form.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@ function FieldMetadata({ className, ...props }: ComponentProps<"div"> & { field:
1919
);
2020
}
2121

22-
function Input(props: PropsWithChildren<ComponentProps<"input"> & { label: string; before?: ReactNode }>) {
22+
function Input({
23+
children,
24+
before,
25+
label,
26+
...props
27+
}: PropsWithChildren<ComponentProps<"input"> & { label: string; before?: ReactNode }>) {
2328
const field = useFieldContext<string>();
2429

2530
return (
2631
<label htmlFor={field.name}>
27-
<span>{props.label}</span>
32+
<span>{label}</span>
2833
<div data-input-group>
29-
{props.before}
34+
{before}
3035
<input
36+
{...props}
3137
aria-invalid={field.state.meta.isTouched && field.state.meta.errors.length > 0}
3238
id={field.name}
3339
name={field.name}
@@ -40,7 +46,7 @@ function Input(props: PropsWithChildren<ComponentProps<"input"> & { label: strin
4046
}}
4147
/>
4248
</div>
43-
{props.children ? <>{props.children}</> : null}
49+
{children ? <>{children}</> : null}
4450
<FieldMetadata field={field} />
4551
</label>
4652
);

0 commit comments

Comments
 (0)