Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fields] Fix autoComplete attribute propagation #12554

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ const PickersInputBase = React.forwardRef(function PickersInputBase(
inputProps,
inputRef,
sectionListRef,
autoComplete,
...other
} = props;

Expand Down Expand Up @@ -296,6 +297,7 @@ const PickersInputBase = React.forwardRef(function PickersInputBase(
: null}
<PickersInputBaseInput
name={name}
autoComplete={autoComplete}
className={classes.input}
value={value}
onChange={onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export interface PickersInputPropsUsedByField
* For a range value, it means that `value === [null, null]`
*/
areAllSectionsEmpty: boolean;
/**
* This prop helps users to fill forms faster, especially on mobile devices.
* The name can be confusing, as it's more like an autofill.
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
*/
autoComplete?: string;

onClick: React.MouseEventHandler<HTMLDivElement>;
onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const PickersTextField = React.forwardRef(function PickersTextField(
variant = 'outlined',
required = false,
// Props used by PickersInput
autoComplete,
InputProps,
inputProps,
inputRef,
Expand Down Expand Up @@ -156,6 +157,7 @@ const PickersTextField = React.forwardRef(function PickersTextField(
name={name}
role="group"
aria-labelledby={inputLabelId}
autoComplete={autoComplete}
{...InputProps}
/>
{helperText && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export interface UseFieldV6ForwardedProps {
onClick?: React.MouseEventHandler;
onFocus?: () => void;
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
autoComplete?: string;
}

interface UseFieldV6AdditionalProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const useFieldV6TextField: UseFieldTextField<false> = (params) => {
const focusTimeoutRef = React.useRef<ReturnType<typeof setTimeout>>();

const {
forwardedProps: { onFocus, onClick, onPaste, onBlur, inputRef: inputRefProp },
forwardedProps: { onFocus, onClick, onPaste, onBlur, inputRef: inputRefProp, autoComplete },
internalProps: { readOnly = false },
parsedSelectedSections,
activeSectionIndex,
Expand Down Expand Up @@ -439,7 +439,7 @@ export const useFieldV6TextField: UseFieldTextField<false> = (params) => {
enableAccessibleFieldDOMStructure: false,
placeholder,
inputMode,
autoComplete: 'off',
autoComplete: autoComplete ?? 'off',
value: shouldShowPlaceholder ? '' : valueStr,
onChange: handleInputChange,
},
Expand Down
Loading