Skip to content

Commit fbaf05b

Browse files
authored
fix: add autoComplete support (#46)
1 parent 6b05aff commit fbaf05b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Picker.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export interface PickerSharedProps<DateType> extends React.AriaAttributes {
8282
role?: string;
8383
name?: string;
8484

85+
autoComplete?: string;
86+
8587
direction?: 'ltr' | 'rtl';
8688
}
8789

@@ -163,6 +165,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
163165
onContextMenu,
164166
onClick,
165167
direction,
168+
autoComplete,
166169
} = props as MergedPickerProps<DateType>;
167170

168171
const inputRef = React.useRef<HTMLInputElement>(null);
@@ -469,6 +472,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
469472
{...inputProps}
470473
size={getInputSize(picker, formatList[0])}
471474
{...getDataOrAriaProps(props)}
475+
autoComplete={autoComplete}
472476
/>
473477
{suffixNode}
474478
{clearNode}

tests/picker.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,10 @@ describe('Picker.Basic', () => {
504504
expect(wrapper.render()).toMatchSnapshot();
505505
});
506506

507-
it('support name prop', () => {
508-
const wrapper = mount(<MomentPicker name="bamboo" />);
507+
it('support name & autoComplete prop', () => {
508+
const wrapper = mount(<MomentPicker name="bamboo" autoComplete="off" />);
509509

510-
expect(wrapper.find('input').props().name).toEqual('bamboo');
510+
expect(wrapper.find('input').props()).toMatchObject({ name: 'bamboo', autoComplete: 'off' });
511511
});
512512

513513
it('blur should reset invalidate text', () => {

0 commit comments

Comments
 (0)