fix(ui): correctly thread through the autoComplete attribute from admin config to the text input (#12473)

We've already supported `autoComplete` on admin config for text fields
but it wasn't being threaded through to the text input element so it
couldn't be applied.
This commit is contained in:
Paul
2025-06-03 10:54:51 -07:00
committed by GitHub
parent 505eaa2bba
commit 08ec837339
4 changed files with 13 additions and 2 deletions

View File

@@ -52,6 +52,9 @@ export function EmailAndUsernameFields(props: RenderEmailAndUsernameFieldsProps)
<TextField <TextField
field={{ field={{
name: 'username', name: 'username',
admin: {
autoComplete: 'off',
},
label: t('authentication:username'), label: t('authentication:username'),
required: loginWithUsername && loginWithUsername.requireUsername, required: loginWithUsername && loginWithUsername.requireUsername,
}} }}

View File

@@ -25,6 +25,7 @@ export const TextInput: React.FC<TextInputProps> = (props) => {
description, description,
Error, Error,
hasMany, hasMany,
htmlAttributes,
inputRef, inputRef,
Label, Label,
label, label,
@@ -158,6 +159,7 @@ export const TextInput: React.FC<TextInputProps> = (props) => {
ref={inputRef} ref={inputRef}
type="text" type="text"
value={value || ''} value={value || ''}
{...(htmlAttributes ?? {})}
/> />
)} )}
{AfterInput} {AfterInput}

View File

@@ -21,7 +21,7 @@ const TextFieldComponent: TextFieldClientComponent = (props) => {
const { const {
field, field,
field: { field: {
admin: { className, description, placeholder, rtl } = {}, admin: { autoComplete, className, description, placeholder, rtl } = {},
hasMany, hasMany,
label, label,
localized, localized,
@@ -123,6 +123,9 @@ const TextFieldComponent: TextFieldClientComponent = (props) => {
description={description} description={description}
Error={Error} Error={Error}
hasMany={hasMany} hasMany={hasMany}
htmlAttributes={{
autoComplete: autoComplete || undefined,
}}
inputRef={inputRef} inputRef={inputRef}
Label={Label} Label={Label}
label={label} label={label}

View File

@@ -1,5 +1,5 @@
import type { StaticDescription, StaticLabel } from 'payload' import type { StaticDescription, StaticLabel } from 'payload'
import type { ChangeEvent } from 'react' import type { ChangeEvent, JSX } from 'react'
import type React from 'react' import type React from 'react'
import type { Option, ReactSelectAdapterProps } from '../../elements/ReactSelect/types.js' import type { Option, ReactSelectAdapterProps } from '../../elements/ReactSelect/types.js'
@@ -21,6 +21,9 @@ export type TextInputProps = {
readonly Description?: React.ReactNode readonly Description?: React.ReactNode
readonly description?: StaticDescription readonly description?: StaticDescription
readonly Error?: React.ReactNode readonly Error?: React.ReactNode
readonly htmlAttributes?: {
autoComplete?: JSX.IntrinsicElements['input']['autoComplete']
}
readonly inputRef?: React.RefObject<HTMLInputElement> readonly inputRef?: React.RefObject<HTMLInputElement>
readonly Label?: React.ReactNode readonly Label?: React.ReactNode
readonly label?: StaticLabel readonly label?: StaticLabel