From 58053505204a782eaa89dfcfa971f4d8ba320858 Mon Sep 17 00:00:00 2001 From: zombiej Date: Sat, 2 May 2020 20:13:38 +0800 Subject: [PATCH 1/2] feat: support picker id --- src/Picker.tsx | 3 +++ tests/picker.spec.tsx | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/Picker.tsx b/src/Picker.tsx index 6b1ecc670..1854d6c27 100644 --- a/src/Picker.tsx +++ b/src/Picker.tsx @@ -49,6 +49,7 @@ export interface PickerSharedProps extends React.AriaAttributes { defaultOpen?: boolean; /** Make input readOnly to avoid popup keyboard in mobile */ inputReadOnly?: boolean; + id?: string; // Value format?: string | string[]; @@ -127,6 +128,7 @@ interface MergedPickerProps function InnerPicker(props: PickerProps) { const { prefixCls = 'rc-picker', + id, style, className, dropdownClassName, @@ -477,6 +479,7 @@ function InnerPicker(props: PickerProps) { size={getInputSize(picker, formatList[0])} {...getDataOrAriaProps(props)} autoComplete={autoComplete} + id={id} /> {suffixNode} {clearNode} diff --git a/tests/picker.spec.tsx b/tests/picker.spec.tsx index aa2e7d2b5..1d97c30d2 100644 --- a/tests/picker.spec.tsx +++ b/tests/picker.spec.tsx @@ -612,4 +612,9 @@ describe('Picker.Basic', () => { expect(wrapper.find('input').props().value).toEqual(text); }); }); + + it('id', () => { + const wrapper = mount(); + expect(wrapper.find('input').props().id).toEqual('light'); + }); }); From 2d1d0319491705b1c9a0fc5d9002a9448a5271ae Mon Sep 17 00:00:00 2001 From: zombiej Date: Sat, 2 May 2020 20:18:08 +0800 Subject: [PATCH 2/2] rangepicker --- src/Picker.tsx | 2 +- src/RangePicker.tsx | 3 +++ tests/range.spec.tsx | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Picker.tsx b/src/Picker.tsx index 1854d6c27..e9124224e 100644 --- a/src/Picker.tsx +++ b/src/Picker.tsx @@ -465,6 +465,7 @@ function InnerPicker(props: PickerProps) { >
(props: PickerProps) { size={getInputSize(picker, formatList[0])} {...getDataOrAriaProps(props)} autoComplete={autoComplete} - id={id} /> {suffixNode} {clearNode} diff --git a/src/RangePicker.tsx b/src/RangePicker.tsx index 804c89f21..820c9d727 100644 --- a/src/RangePicker.tsx +++ b/src/RangePicker.tsx @@ -55,6 +55,7 @@ function canValueTrigger( } export interface RangePickerSharedProps { + id?: string; value?: RangeValue; defaultValue?: RangeValue; defaultPickerValue?: [DateType, DateType]; @@ -136,6 +137,7 @@ interface MergedRangePickerProps function InnerRangePicker(props: RangePickerProps) { const { prefixCls = 'rc-picker', + id, style, className, popupStyle, @@ -887,6 +889,7 @@ function InnerRangePicker(props: RangePickerProps) { ref={startInputDivRef} > { testOrderOnTime(false, '23:00:00', '02:00:00'); testOrderOnTime(true, '02:00:00', '23:00:00'); }); + + it('id', () => { + const wrapper = mount(); + expect( + wrapper + .find('input') + .first() + .props().id, + ).toEqual('bamboo'); + }); });