Skip to content
Merged
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
3 changes: 3 additions & 0 deletions src/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface PickerSharedProps<DateType> extends React.AriaAttributes {
defaultOpen?: boolean;
/** Make input readOnly to avoid popup keyboard in mobile */
inputReadOnly?: boolean;
id?: string;

// Value
format?: string | string[];
Expand Down Expand Up @@ -127,6 +128,7 @@ interface MergedPickerProps<DateType>
function InnerPicker<DateType>(props: PickerProps<DateType>) {
const {
prefixCls = 'rc-picker',
id,
style,
className,
dropdownClassName,
Expand Down Expand Up @@ -463,6 +465,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
>
<div className={`${prefixCls}-input`} ref={inputDivRef}>
<input
id={id}
disabled={disabled}
readOnly={inputReadOnly || !typing}
value={text}
Expand Down
3 changes: 3 additions & 0 deletions src/RangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function canValueTrigger<DateType>(
}

export interface RangePickerSharedProps<DateType> {
id?: string;
value?: RangeValue<DateType>;
defaultValue?: RangeValue<DateType>;
defaultPickerValue?: [DateType, DateType];
Expand Down Expand Up @@ -136,6 +137,7 @@ interface MergedRangePickerProps<DateType>
function InnerRangePicker<DateType>(props: RangePickerProps<DateType>) {
const {
prefixCls = 'rc-picker',
id,
style,
className,
popupStyle,
Expand Down Expand Up @@ -887,6 +889,7 @@ function InnerRangePicker<DateType>(props: RangePickerProps<DateType>) {
ref={startInputDivRef}
>
<input
id={id}
disabled={mergedDisabled[0]}
readOnly={inputReadOnly || !startTyping}
value={startText}
Expand Down
5 changes: 5 additions & 0 deletions tests/picker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -612,4 +612,9 @@ describe('Picker.Basic', () => {
expect(wrapper.find('input').props().value).toEqual(text);
});
});

it('id', () => {
const wrapper = mount(<MomentPicker id="light" />);
expect(wrapper.find('input').props().id).toEqual('light');
});
});
10 changes: 10 additions & 0 deletions tests/range.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1036,4 +1036,14 @@ describe('Picker.Range', () => {
testOrderOnTime(false, '23:00:00', '02:00:00');
testOrderOnTime(true, '02:00:00', '23:00:00');
});

it('id', () => {
const wrapper = mount(<MomentRangePicker id="bamboo" />);
expect(
wrapper
.find('input')
.first()
.props().id,
).toEqual('bamboo');
});
});