mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-01 13:33:48 +08:00
fix(setting-model): support field-level autoComplete to suppress browser autofill (#17559)
This commit is contained in:
@@ -93,6 +93,14 @@ export interface FormFieldConfig {
|
||||
labelClassName?: string;
|
||||
className?: string;
|
||||
disabled?: boolean;
|
||||
/**
|
||||
* HTML `autocomplete` attribute forwarded to the underlying `<input>`.
|
||||
* Use `'new-password'` to suppress browser autofill — Chrome ignores
|
||||
* `'off'` on forms that contain a password field (treats them as login
|
||||
* forms), so `'new-password'` is the reliable value for autofill-prone
|
||||
* fields like api_key / instance_name / base_url / group_id.
|
||||
*/
|
||||
autoComplete?: string;
|
||||
}
|
||||
|
||||
// Component props interface
|
||||
@@ -613,6 +621,7 @@ export const RenderField = ({
|
||||
type={field.type}
|
||||
placeholder={field.placeholder}
|
||||
disabled={field.disabled}
|
||||
autoComplete={field.autoComplete}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -32,6 +32,7 @@ export const GenericApiKeyConfig: ProviderConfig = {
|
||||
required: true,
|
||||
placeholder: 'instanceNameMessage',
|
||||
tooltip: 'instanceNameTip',
|
||||
autoComplete: 'new-password',
|
||||
validation: { message: 'instanceNameMessage' },
|
||||
},
|
||||
{
|
||||
@@ -40,6 +41,7 @@ export const GenericApiKeyConfig: ProviderConfig = {
|
||||
type: FormFieldType.Password,
|
||||
required: true,
|
||||
placeholder: 'apiKeyMessage',
|
||||
autoComplete: 'new-password',
|
||||
validation: { message: 'apiKeyMessage' },
|
||||
},
|
||||
{
|
||||
@@ -64,6 +66,7 @@ export const GenericApiKeyConfig: ProviderConfig = {
|
||||
return 'openaiBaseUrlPlaceholder';
|
||||
},
|
||||
shouldRender: 'showBaseUrl',
|
||||
autoComplete: 'new-password',
|
||||
},
|
||||
{
|
||||
name: 'group_id',
|
||||
@@ -71,6 +74,7 @@ export const GenericApiKeyConfig: ProviderConfig = {
|
||||
type: FormFieldType.Text,
|
||||
required: false,
|
||||
shouldRender: 'showGroupId',
|
||||
autoComplete: 'new-password',
|
||||
},
|
||||
],
|
||||
verifyTransform: (values) => ({
|
||||
|
||||
@@ -209,6 +209,7 @@ export const useProviderFields = ({
|
||||
value: o.value,
|
||||
})) as any,
|
||||
defaultValue: field.defaultValue,
|
||||
autoComplete: field.autoComplete,
|
||||
validation,
|
||||
shouldRender: resolveShouldRender(field.shouldRender),
|
||||
// In viewMode, only the model-related fields are editable.
|
||||
@@ -245,7 +246,11 @@ export const useProviderFields = ({
|
||||
placeholder={placeholderText}
|
||||
/>
|
||||
) : (
|
||||
<Input {...fieldProps} placeholder={placeholderText} />
|
||||
<Input
|
||||
{...fieldProps}
|
||||
placeholder={placeholderText}
|
||||
autoComplete={field.autoComplete}
|
||||
/>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -85,6 +85,12 @@ export interface FieldConfig {
|
||||
options?: SelectOption[];
|
||||
/** Default value */
|
||||
defaultValue?: any;
|
||||
/**
|
||||
* HTML `autocomplete` attribute forwarded to the underlying `<input>`.
|
||||
* Use `'new-password'` to suppress browser autofill (Chrome ignores
|
||||
* `'off'` on forms containing a password field).
|
||||
*/
|
||||
autoComplete?: string;
|
||||
/**
|
||||
* Validation rules.
|
||||
* `message` is treated as an i18n key by the ProviderModal and translated
|
||||
|
||||
Reference in New Issue
Block a user