From d1ac522d9632d7e6c81170cc876494b50bd529af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Sun, 27 Nov 2022 22:28:29 +0800 Subject: [PATCH] fix: TimePicker `popupClassName` unexpect warning (#39010) --- .../date-picker/__tests__/DatePicker.test.tsx | 13 +++++++++++++ .../generatePicker/generateRangePicker.tsx | 2 +- .../generatePicker/generateSinglePicker.tsx | 4 ++-- components/time-picker/__tests__/index.test.tsx | 14 ++++++++++++++ components/time-picker/index.tsx | 12 ++++-------- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/components/date-picker/__tests__/DatePicker.test.tsx b/components/date-picker/__tests__/DatePicker.test.tsx index 68c61f1265..b58b3cd0cb 100644 --- a/components/date-picker/__tests__/DatePicker.test.tsx +++ b/components/date-picker/__tests__/DatePicker.test.tsx @@ -227,6 +227,12 @@ describe('DatePicker', () => { 'Warning: [antd: DatePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', ); }); + it('DatePicker should show warning when use popupClassName', () => { + render(); + expect(errorSpy).not.toHaveBeenCalledWith( + 'Warning: [antd: DatePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', + ); + }); it('RangePicker should show warning when use dropdownClassName', () => { render(); @@ -235,6 +241,13 @@ describe('DatePicker', () => { ); }); + it('RangePicker should show warning when use popupClassName', () => { + render(); + expect(errorSpy).not.toHaveBeenCalledWith( + 'Warning: [antd: RangePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', + ); + }); + it('DatePicker.RangePicker with defaultPickerValue and showTime', () => { const startDate = moment('1982-02-12'); const endDate = moment('1982-02-22'); diff --git a/components/date-picker/generatePicker/generateRangePicker.tsx b/components/date-picker/generatePicker/generateRangePicker.tsx index e96a378caa..3aab483273 100644 --- a/components/date-picker/generatePicker/generateRangePicker.tsx +++ b/components/date-picker/generatePicker/generateRangePicker.tsx @@ -109,7 +109,6 @@ export default function generateRangePicker(generateConfig: GenerateCo } disabled={mergedDisabled} ref={innerRef} - dropdownClassName={popupClassName || dropdownClassName} dropdownAlign={transPlacement2DropdownAlign(direction, placement)} placeholder={getRangePlaceholder(picker, locale, placeholder)} suffixIcon={suffixNode} @@ -141,6 +140,7 @@ export default function generateRangePicker(generateConfig: GenerateCo generateConfig={generateConfig} components={Components} direction={direction} + dropdownClassName={popupClassName || dropdownClassName} /> ); }} diff --git a/components/date-picker/generatePicker/generateSinglePicker.tsx b/components/date-picker/generatePicker/generateSinglePicker.tsx index 7cb9400651..61dab0a522 100644 --- a/components/date-picker/generatePicker/generateSinglePicker.tsx +++ b/components/date-picker/generatePicker/generateSinglePicker.tsx @@ -95,7 +95,7 @@ export default function generatePicker(generateConfig: GenerateConfig< warning( !dropdownClassName, - 'DatePicker', + mergedPicker === 'time' ? 'TimePicker' : 'DatePicker', '`dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', ); // ===================== Size ===================== @@ -128,7 +128,6 @@ export default function generatePicker(generateConfig: GenerateConfig< placeholder={getPlaceholder(mergedPicker, locale, placeholder)} suffixIcon={suffixNode} dropdownAlign={transPlacement2DropdownAlign(direction, placement)} - dropdownClassName={popupClassName || dropdownClassName} clearIcon={} prevIcon={} nextIcon={} @@ -159,6 +158,7 @@ export default function generatePicker(generateConfig: GenerateConfig< components={Components} direction={direction} disabled={mergedDisabled} + dropdownClassName={popupClassName || dropdownClassName} /> ); }} diff --git a/components/time-picker/__tests__/index.test.tsx b/components/time-picker/__tests__/index.test.tsx index 034e244d87..9c28e4303d 100644 --- a/components/time-picker/__tests__/index.test.tsx +++ b/components/time-picker/__tests__/index.test.tsx @@ -95,6 +95,13 @@ describe('TimePicker', () => { ); }); + it('RangePicker should show warning when use popupClassName', () => { + render(); + expect(errorSpy).not.toHaveBeenCalledWith( + 'Warning: [antd: RangePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', + ); + }); + it('TimePicker should show warning when use dropdownClassName', () => { render(); expect(errorSpy).toHaveBeenCalledWith( @@ -102,6 +109,13 @@ describe('TimePicker', () => { ); }); + it('TimePicker should show warning when use popupClassName', () => { + render(); + expect(errorSpy).not.toHaveBeenCalledWith( + 'Warning: [antd: TimePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', + ); + }); + it('should support bordered', () => { const { container } = render( ((props, ref) => return ( ( return undefined; }, [addon, renderExtraFooter]); - warning( - !dropdownClassName, - 'TimePicker', - '`dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', - ); - return (