From e20892c718b51e39f225371b080226eb7f291ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Fri, 10 Jan 2025 02:20:50 +0800 Subject: [PATCH 1/5] feat: rename dropdown to popup --- src/BaseSelect/index.tsx | 45 ++++++++++++++++++++++----- src/Select.tsx | 9 ++++-- src/SelectTrigger.tsx | 58 +++++++++++++++++------------------ src/utils/warningPropsUtil.ts | 22 +++++++++++++ 4 files changed, 95 insertions(+), 39 deletions(-) diff --git a/src/BaseSelect/index.tsx b/src/BaseSelect/index.tsx index a2a15e8c7..0931938d8 100644 --- a/src/BaseSelect/index.tsx +++ b/src/BaseSelect/index.tsx @@ -155,7 +155,9 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri // >>> Open open?: boolean; defaultOpen?: boolean; + /** @deprecated Please use `onPopupVisibleChange` instead */ onDropdownVisibleChange?: (open: boolean) => void; + onPopupVisibleChange?: (open: boolean) => void; // >>> Customize Input /** @private Internal usage. Do not use in your production. */ @@ -183,14 +185,30 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri /** Selector remove icon */ removeIcon?: RenderNode; - // >>> Dropdown + // >>> Dropdown/Popup animation?: string; transitionName?: string; + + /** @deprecated Please use `popupStyle` instead */ dropdownStyle?: React.CSSProperties; + popupStyle?: React.CSSProperties; + + /** @deprecated Please use `popupClassName` instead */ dropdownClassName?: string; + popupClassName?: string; + + /** @deprecated Please use `popupMatchSelectWidth` instead */ dropdownMatchSelectWidth?: boolean | number; + popupMatchSelectWidth?: boolean | number; + + /** @deprecated Please use `popupRender` instead */ dropdownRender?: (menu: React.ReactElement) => React.ReactElement; + popupRender?: (menu: React.ReactElement) => React.ReactElement; + + /** @deprecated Please use `popupAlign` instead */ dropdownAlign?: AlignType; + popupAlign?: AlignType; + placement?: Placement; builtinPlacements?: BuildInPlacements; getPopupContainer?: RenderDOMFunc; @@ -245,6 +263,7 @@ const BaseSelect = React.forwardRef((props, ref) open, defaultOpen, onDropdownVisibleChange, + onPopupVisibleChange, // Active activeValue, @@ -269,10 +288,15 @@ const BaseSelect = React.forwardRef((props, ref) animation, transitionName, dropdownStyle, + popupStyle, dropdownClassName, + popupClassName, dropdownMatchSelectWidth, + popupMatchSelectWidth, dropdownRender, + popupRender, dropdownAlign, + popupAlign, placement, builtinPlacements, getPopupContainer, @@ -308,6 +332,12 @@ const BaseSelect = React.forwardRef((props, ref) delete domProps[propName]; }); + // ============================= Compitable ============================= + const mergedPopupStyle = popupStyle ?? dropdownStyle; + const mergedPopupClassName = popupClassName ?? dropdownClassName; + const mergedPopupRender = popupRender ?? dropdownRender; + const mergedPopupAlign = popupAlign ?? dropdownAlign; + // ============================= Mobile ============================= const [mobile, setMobile] = React.useState(false); React.useEffect(() => { @@ -389,10 +419,11 @@ const BaseSelect = React.forwardRef((props, ref) if (mergedOpen !== nextOpen) { onDropdownVisibleChange?.(nextOpen); + onPopupVisibleChange?.(nextOpen); } } }, - [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange], + [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange, onPopupVisibleChange], ); // ============================= Search ============================= @@ -766,12 +797,12 @@ const BaseSelect = React.forwardRef((props, ref) popupElement={optionList} animation={animation} transitionName={transitionName} - dropdownStyle={dropdownStyle} - dropdownClassName={dropdownClassName} + popupStyle={mergedPopupStyle} + popupClassName={mergedPopupClassName} direction={direction} - dropdownMatchSelectWidth={dropdownMatchSelectWidth} - dropdownRender={dropdownRender} - dropdownAlign={dropdownAlign} + popupMatchSelectWidth={popupMatchSelectWidth} + popupRender={mergedPopupRender} + popupAlign={mergedPopupAlign} placement={placement} builtinPlacements={builtinPlacements} getPopupContainer={getPopupContainer} diff --git a/src/Select.tsx b/src/Select.tsx index 3233b5a21..0104e046d 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -181,6 +181,7 @@ const Select = React.forwardRef(() => { - const realVirtual = virtual !== false && dropdownMatchSelectWidth !== false; + const realVirtual = virtual !== false && mergedPopupMatchSelectWidth !== false; return { ...parsedOptions, flattenOptions: displayOptions, @@ -638,7 +641,7 @@ const Select = React.forwardRef>> OptionList OptionList={OptionList} emptyOptions={!displayOptions.length} diff --git a/src/SelectTrigger.tsx b/src/SelectTrigger.tsx index 960febf4b..6eca94f33 100644 --- a/src/SelectTrigger.tsx +++ b/src/SelectTrigger.tsx @@ -5,10 +5,10 @@ import * as React from 'react'; import type { Placement, RenderDOMFunc } from './BaseSelect'; const getBuiltInPlacements = ( - dropdownMatchSelectWidth: number | boolean, + popupMatchSelectWidth: number | boolean, ): Record => { // Enable horizontal overflow auto-adjustment when a custom dropdown width is provided - const adjustX = dropdownMatchSelectWidth === true ? 0 : 1; + const adjustX = popupMatchSelectWidth === true ? 0 : 1; return { bottomLeft: { points: ['tl', 'bl'], @@ -64,13 +64,13 @@ export interface SelectTriggerProps { transitionName?: string; placement?: Placement; builtinPlacements?: BuildInPlacements; - dropdownStyle: React.CSSProperties; - dropdownClassName: string; + popupStyle: React.CSSProperties; + popupClassName: string; direction: string; - dropdownMatchSelectWidth?: boolean | number; - dropdownRender?: (menu: React.ReactElement) => React.ReactElement; + popupMatchSelectWidth?: boolean | number; + popupRender?: (menu: React.ReactElement) => React.ReactElement; getPopupContainer?: RenderDOMFunc; - dropdownAlign: AlignType; + popupAlign: AlignType; empty: boolean; getTriggerDOMNode: (node: HTMLElement) => HTMLElement; @@ -91,14 +91,14 @@ const SelectTrigger: React.ForwardRefRenderFunction builtinPlacements || getBuiltInPlacements(dropdownMatchSelectWidth), - [builtinPlacements, dropdownMatchSelectWidth], + () => builtinPlacements || getBuiltInPlacements(popupMatchSelectWidth), + [builtinPlacements, popupMatchSelectWidth], ); // ===================== Motion ====================== - const mergedTransitionName = animation ? `${dropdownPrefixCls}-${animation}` : transitionName; + const mergedTransitionName = animation ? `${popupPrefixCls}-${animation}` : transitionName; // =================== Popup Width =================== - const isNumberPopupWidth = typeof dropdownMatchSelectWidth === 'number'; + const isNumberPopupWidth = typeof popupMatchSelectWidth === 'number'; const stretch = React.useMemo(() => { if (isNumberPopupWidth) { return null; } - return dropdownMatchSelectWidth === false ? 'minWidth' : 'width'; - }, [dropdownMatchSelectWidth, isNumberPopupWidth]); + return popupMatchSelectWidth === false ? 'minWidth' : 'width'; + }, [popupMatchSelectWidth, isNumberPopupWidth]); - let popupStyle = dropdownStyle; + let mergedPopupStyle = popupStyle; if (isNumberPopupWidth) { - popupStyle = { + mergedPopupStyle = { ...popupStyle, - width: dropdownMatchSelectWidth, + width: popupMatchSelectWidth, }; } @@ -156,18 +156,18 @@ const SelectTrigger: React.ForwardRefRenderFunction{popupNode}} ref={triggerPopupRef} stretch={stretch} - popupAlign={dropdownAlign} + popupAlign={popupAlign} popupVisible={visible} getPopupContainer={getPopupContainer} - popupClassName={classNames(dropdownClassName, { - [`${dropdownPrefixCls}-empty`]: empty, + popupClassName={classNames(popupClassName, { + [`${popupPrefixCls}-empty`]: empty, })} - popupStyle={popupStyle} + popupStyle={mergedPopupStyle} getTriggerDOMNode={getTriggerDOMNode} onPopupVisibleChange={onPopupVisibleChange} > diff --git a/src/utils/warningPropsUtil.ts b/src/utils/warningPropsUtil.ts index 7a0fed2ea..9b8ce5db9 100644 --- a/src/utils/warningPropsUtil.ts +++ b/src/utils/warningPropsUtil.ts @@ -149,6 +149,28 @@ function warningProps(props: SelectProps) { ); } } + + // Deprecated API warnings + const deprecatedProps = { + dropdownClassName: 'popupClassName', + dropdownStyle: 'popupStyle', + dropdownAlign: 'popupAlign', + dropdownRender: 'popupRender', + dropdownMatchSelectWidth: 'popupMatchSelectWidth', + }; + + Object.entries(deprecatedProps).forEach(([deprecatedProp, newProp]) => { + if (deprecatedProp in props) { + warning(false, `'${deprecatedProp}' is deprecated. Please use '${newProp}' instead.`); + } + }); + + if ('onDropdownVisibleChange' in props) { + warning( + false, + '`onDropdownVisibleChange` is deprecated. Please use `onPopupVisibleChange` instead.', + ); + } } // value in Select option should not be null From 236853d18e2fec01101e4e43bd39e0ddefeeef27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Fri, 10 Jan 2025 02:26:47 +0800 Subject: [PATCH 2/5] chore: adjust some logic --- src/BaseSelect/index.tsx | 4 ++-- src/Select.tsx | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/BaseSelect/index.tsx b/src/BaseSelect/index.tsx index 0931938d8..308374db6 100644 --- a/src/BaseSelect/index.tsx +++ b/src/BaseSelect/index.tsx @@ -337,7 +337,7 @@ const BaseSelect = React.forwardRef((props, ref) const mergedPopupClassName = popupClassName ?? dropdownClassName; const mergedPopupRender = popupRender ?? dropdownRender; const mergedPopupAlign = popupAlign ?? dropdownAlign; - + const mergedPopupMatchSelectWidth = popupMatchSelectWidth ?? dropdownMatchSelectWidth; // ============================= Mobile ============================= const [mobile, setMobile] = React.useState(false); React.useEffect(() => { @@ -800,7 +800,7 @@ const BaseSelect = React.forwardRef((props, ref) popupStyle={mergedPopupStyle} popupClassName={mergedPopupClassName} direction={direction} - popupMatchSelectWidth={popupMatchSelectWidth} + popupMatchSelectWidth={mergedPopupMatchSelectWidth} popupRender={mergedPopupRender} popupAlign={mergedPopupAlign} placement={placement} diff --git a/src/Select.tsx b/src/Select.tsx index 0104e046d..fd2068a88 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -609,10 +609,8 @@ const Select = React.forwardRef(() => { - const realVirtual = virtual !== false && mergedPopupMatchSelectWidth !== false; + const realVirtual = virtual !== false && popupMatchSelectWidth !== false; return { ...parsedOptions, flattenOptions: displayOptions, @@ -641,7 +639,7 @@ const Select = React.forwardRef>> OptionList OptionList={OptionList} emptyOptions={!displayOptions.length} From dc4a7d44f9bee393a9a15a7ef2ce46f60c6936d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Fri, 10 Jan 2025 14:25:12 +0800 Subject: [PATCH 3/5] test: add test case --- src/utils/warningPropsUtil.ts | 2 +- tests/Select.test.tsx | 88 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/utils/warningPropsUtil.ts b/src/utils/warningPropsUtil.ts index 9b8ce5db9..043464a18 100644 --- a/src/utils/warningPropsUtil.ts +++ b/src/utils/warningPropsUtil.ts @@ -161,7 +161,7 @@ function warningProps(props: SelectProps) { Object.entries(deprecatedProps).forEach(([deprecatedProp, newProp]) => { if (deprecatedProp in props) { - warning(false, `'${deprecatedProp}' is deprecated. Please use '${newProp}' instead.`); + warning(false, `\`${deprecatedProp}\` is deprecated. Please use \`${newProp}\` instead.`); } }); diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 47d430e1d..6093b118a 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -2368,3 +2368,91 @@ describe('Select.Basic', () => { expect(element[1]).toHaveClass('rc-select-item-option-disabled'); }); }); + +describe('Select.Deprecated APIs', () => { + beforeAll(() => { + jest.useFakeTimers(); + }); + + afterAll(() => { + jest.useRealTimers(); + }); + + beforeEach(() => { + resetWarned(); + }); + + const deprecatedAPIs = { + dropdownClassName: 'popupClassName', + dropdownStyle: 'popupStyle', + dropdownAlign: 'popupAlign', + dropdownRender: 'popupRender', + dropdownMatchSelectWidth: 'popupMatchSelectWidth', + onDropdownVisibleChange: 'onPopupVisibleChange', + }; + + Object.entries(deprecatedAPIs).forEach(([deprecatedProp, newProp]) => { + it(`should warning if use deprecated API '${deprecatedProp}'`, () => { + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + + const props = { + [deprecatedProp]: deprecatedProp === 'dropdownRender' ? (menu) => menu : true, + }; + + render( + , + ); + + expect(errorSpy).toHaveBeenCalledWith( + `Warning: \`${deprecatedProp}\` is deprecated. Please use \`${newProp}\` instead.`, + ); + + errorSpy.mockRestore(); + }); + }); + + it('should not warning if use new APIs', () => { + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + + render( + , + ); + + expect(errorSpy).not.toHaveBeenCalled(); + errorSpy.mockRestore(); + }); + + it('should work with both old and new APIs', () => { + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + + const { container } = render( + , + ); + + // Should use new API value + toggleOpen(container); + expect((container.querySelector('.rc-select-dropdown') as HTMLElement).style.width).toBe( + '200px', + ); + + // Should still show warning + expect(errorSpy).toHaveBeenCalledWith( + `Warning: \`dropdownMatchSelectWidth\` is deprecated. Please use \`popupMatchSelectWidth\` instead.`, + ); + + errorSpy.mockRestore(); + }); +}); From 06a2dc57c7fd055c5812733cc759bbb295f72e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Fri, 10 Jan 2025 14:35:14 +0800 Subject: [PATCH 4/5] chore: trigger CI build From 72e4d5c87d0bc91625514616eecca3243a6ad81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Fri, 10 Jan 2025 17:05:14 +0800 Subject: [PATCH 5/5] refactor: remove compatible code --- docs/examples/auto-adjust-dropdown.tsx | 10 +-- docs/examples/controlled.tsx | 4 +- docs/examples/dropdownRender.tsx | 2 +- docs/examples/getPopupContainer.tsx | 6 +- docs/examples/single-animation.tsx | 2 +- docs/examples/single.tsx | 4 +- src/BaseSelect/index.tsx | 41 ++-------- src/Select.tsx | 3 +- src/SelectTrigger.tsx | 6 ++ src/utils/warningPropsUtil.ts | 22 ------ tests/Combobox.test.tsx | 6 +- tests/Custom.test.tsx | 6 +- tests/Popup.test.tsx | 6 +- tests/Select.test.tsx | 104 ++----------------------- 14 files changed, 44 insertions(+), 178 deletions(-) diff --git a/docs/examples/auto-adjust-dropdown.tsx b/docs/examples/auto-adjust-dropdown.tsx index 544d47a98..11e79aaef 100644 --- a/docs/examples/auto-adjust-dropdown.tsx +++ b/docs/examples/auto-adjust-dropdown.tsx @@ -34,14 +34,14 @@ class Test extends React.Component { >
-
- {' '} @@ -50,7 +50,7 @@ class Test extends React.Component {
- @@ -64,14 +64,14 @@ class Test extends React.Component { }} >
-
- diff --git a/docs/examples/controlled.tsx b/docs/examples/controlled.tsx index 539399317..c08872380 100644 --- a/docs/examples/controlled.tsx +++ b/docs/examples/controlled.tsx @@ -43,7 +43,7 @@ class Controlled extends React.Component<{}, ControlledState> { console.log('onFocus'); }; - onDropdownVisibleChange = (open) => { + onPopupVisibleChange = (open) => { this.setState({ open }); }; @@ -68,7 +68,7 @@ class Controlled extends React.Component<{}, ControlledState> { optionLabelProp="children" optionFilterProp="text" onChange={this.onChange} - onDropdownVisibleChange={this.onDropdownVisibleChange} + onPopupVisibleChange={this.onPopupVisibleChange} >
); diff --git a/docs/examples/single-animation.tsx b/docs/examples/single-animation.tsx index b4a70b94c..e1ebc748c 100644 --- a/docs/examples/single-animation.tsx +++ b/docs/examples/single-animation.tsx @@ -21,7 +21,7 @@ const Test = () => ( animation="slide-up" showSearch onChange={onChange} - dropdownStyle={{ + popupStyle={{ width: 'auto', }} > diff --git a/docs/examples/single.tsx b/docs/examples/single.tsx index f305a804a..2ac0fd277 100644 --- a/docs/examples/single.tsx +++ b/docs/examples/single.tsx @@ -130,8 +130,8 @@ class Test extends React.Component { id="my-select-rtl" placeholder="rtl" direction="rtl" - dropdownMatchSelectWidth={300} - dropdownStyle={{ minWidth: 300 }} + popupMatchSelectWidth={300} + popupStyle={{ minWidth: 300 }} style={{ width: 500 }} > diff --git a/src/BaseSelect/index.tsx b/src/BaseSelect/index.tsx index ed1d24d7e..dc8ddb8f7 100644 --- a/src/BaseSelect/index.tsx +++ b/src/BaseSelect/index.tsx @@ -156,8 +156,6 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri // >>> Open open?: boolean; defaultOpen?: boolean; - /** @deprecated Please use `onPopupVisibleChange` instead */ - onDropdownVisibleChange?: (open: boolean) => void; onPopupVisibleChange?: (open: boolean) => void; // >>> Customize Input @@ -190,24 +188,10 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri animation?: string; transitionName?: string; - /** @deprecated Please use `popupStyle` instead */ - dropdownStyle?: React.CSSProperties; popupStyle?: React.CSSProperties; - - /** @deprecated Please use `popupClassName` instead */ - dropdownClassName?: string; popupClassName?: string; - - /** @deprecated Please use `popupMatchSelectWidth` instead */ - dropdownMatchSelectWidth?: boolean | number; popupMatchSelectWidth?: boolean | number; - - /** @deprecated Please use `popupRender` instead */ - dropdownRender?: (menu: React.ReactElement) => React.ReactElement; popupRender?: (menu: React.ReactElement) => React.ReactElement; - - /** @deprecated Please use `popupAlign` instead */ - dropdownAlign?: AlignType; popupAlign?: AlignType; placement?: Placement; @@ -263,7 +247,6 @@ const BaseSelect = React.forwardRef((props, ref) // Open open, defaultOpen, - onDropdownVisibleChange, onPopupVisibleChange, // Active @@ -288,15 +271,10 @@ const BaseSelect = React.forwardRef((props, ref) OptionList, animation, transitionName, - dropdownStyle, popupStyle, - dropdownClassName, popupClassName, - dropdownMatchSelectWidth, popupMatchSelectWidth, - dropdownRender, popupRender, - dropdownAlign, popupAlign, placement, builtinPlacements, @@ -333,12 +311,6 @@ const BaseSelect = React.forwardRef((props, ref) delete domProps[propName]; }); - // ============================= Compitable ============================= - const mergedPopupStyle = popupStyle ?? dropdownStyle; - const mergedPopupClassName = popupClassName ?? dropdownClassName; - const mergedPopupRender = popupRender ?? dropdownRender; - const mergedPopupAlign = popupAlign ?? dropdownAlign; - const mergedPopupMatchSelectWidth = popupMatchSelectWidth ?? dropdownMatchSelectWidth; // ============================= Mobile ============================= const [mobile, setMobile] = React.useState(false); React.useEffect(() => { @@ -419,12 +391,11 @@ const BaseSelect = React.forwardRef((props, ref) setInnerOpen(nextOpen); if (mergedOpen !== nextOpen) { - onDropdownVisibleChange?.(nextOpen); onPopupVisibleChange?.(nextOpen); } } }, - [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange, onPopupVisibleChange], + [disabled, mergedOpen, setInnerOpen, onPopupVisibleChange], ); // ============================= Search ============================= @@ -798,12 +769,12 @@ const BaseSelect = React.forwardRef((props, ref) popupElement={optionList} animation={animation} transitionName={transitionName} - popupStyle={mergedPopupStyle} - popupClassName={mergedPopupClassName} + popupStyle={popupStyle} + popupClassName={popupClassName} direction={direction} - popupMatchSelectWidth={mergedPopupMatchSelectWidth} - popupRender={mergedPopupRender} - popupAlign={mergedPopupAlign} + popupMatchSelectWidth={popupMatchSelectWidth} + popupRender={popupRender} + popupAlign={popupAlign} placement={placement} builtinPlacements={builtinPlacements} getPopupContainer={getPopupContainer} diff --git a/src/Select.tsx b/src/Select.tsx index fd2068a88..748f457ce 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -180,8 +180,7 @@ const Select = React.forwardRef { - if (deprecatedProp in props) { - warning(false, `\`${deprecatedProp}\` is deprecated. Please use \`${newProp}\` instead.`); - } - }); - - if ('onDropdownVisibleChange' in props) { - warning( - false, - '`onDropdownVisibleChange` is deprecated. Please use `onPopupVisibleChange` instead.', - ); - } } // value in Select option should not be null diff --git a/tests/Combobox.test.tsx b/tests/Combobox.test.tsx index 8a8a74737..76601b388 100644 --- a/tests/Combobox.test.tsx +++ b/tests/Combobox.test.tsx @@ -455,16 +455,16 @@ describe('Select.Combobox', () => { // https://github.com/ant-design/ant-design/issues/16572 it('close when enter press without active option', () => { jest.useFakeTimers(); - const onDropdownVisibleChange = jest.fn(); + const onPopupVisibleChange = jest.fn(); const { container } = render( - , ); keyDown(container.querySelector('input')!, KeyCode.ENTER); jest.runAllTimers(); - expect(onDropdownVisibleChange).toHaveBeenCalledWith(false); + expect(onPopupVisibleChange).toHaveBeenCalledWith(false); jest.useRealTimers(); }); diff --git a/tests/Custom.test.tsx b/tests/Custom.test.tsx index 26d3cc14f..eb781adaf 100644 --- a/tests/Custom.test.tsx +++ b/tests/Custom.test.tsx @@ -15,15 +15,15 @@ describe('Select.Custom', () => { }); it('getRawInputElement', () => { - const onDropdownVisibleChange = jest.fn(); + const onPopupVisibleChange = jest.fn(); const { container } = render( document.body} />, ); fireEvent.mouseDown(document.querySelector('.rc-select-dropdown')); - expect(onDropdownVisibleChange).not.toHaveBeenCalled(); + expect(onPopupVisibleChange).not.toHaveBeenCalled(); }); }); diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 6093b118a..6f49bff38 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -315,7 +315,7 @@ describe('Select.Basic', () => { const { container } = render( + ); @@ -1323,7 +1323,7 @@ describe('Select.Basic', () => { const { container } = testingRender( ( + popupRender={(menu) => (