-
-
Notifications
You must be signed in to change notification settings - Fork 145
feat: retire deprecated api and rename to popup #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5851494
4807756
38d47b4
f76b4ec
f569369
d3e31df
ced37ee
5858fb8
39a61a8
c911ae5
96b19ee
f442210
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ | |
| "@types/classnames": "^2.2.6", | ||
| "@types/enzyme": "^3.1.15", | ||
| "@types/jest": "^29.4.0", | ||
| "@types/react": "^17.0.38", | ||
| "@types/react": "^18.0.38", | ||
|
||
| "@types/react-dom": "^18.0.11", | ||
| "@types/warning": "^3.0.0", | ||
| "@umijs/fabric": "^4.0.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ import { | |
| toRawValues, | ||
| } from './utils/commonUtil'; | ||
| import { formatStrategyValues, toPathOptions } from './utils/treeUtil'; | ||
| import warningProps, { warningNullOptions } from './utils/warningPropsUtil'; | ||
| import { warningNullOptions } from './utils/warningPropsUtil'; | ||
|
|
||
| export interface BaseOptionType { | ||
| disabled?: boolean; | ||
|
|
@@ -67,9 +67,9 @@ interface BaseCascaderProps< | |
| OptionType extends DefaultOptionType = DefaultOptionType, | ||
| ValueField extends keyof OptionType = keyof OptionType, | ||
| > extends Omit< | ||
| BaseSelectPropsWithoutPrivate, | ||
| 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch' | ||
| > { | ||
| BaseSelectPropsWithoutPrivate, | ||
| 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch' | ||
| > { | ||
| // MISC | ||
| id?: string; | ||
| prefixCls?: string; | ||
|
|
@@ -95,18 +95,14 @@ interface BaseCascaderProps< | |
| // Options | ||
| options?: OptionType[]; | ||
| /** @private Internal usage. Do not use in your production. */ | ||
| dropdownPrefixCls?: string; | ||
| popupPrefixCls?: string; | ||
| loadData?: (selectOptions: OptionType[]) => void; | ||
|
|
||
| // Open | ||
| /** @deprecated Use `open` instead */ | ||
| popupVisible?: boolean; | ||
|
|
||
| popupClassName?: string; | ||
| /** @deprecated Use `popupMenuColumnStyle` instead */ | ||
| dropdownMenuColumnStyle?: React.CSSProperties; | ||
| popupMenuColumnStyle?: React.CSSProperties; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Verification inconclusive缺少类名属性更新
popupClassName?: string;
+/** @deprecated Use `dropdownClassName` instead */🏁 Script executed: #!/bin/bash
# 检查测试中是否使用了 dropdownClassName
grep -n "dropdownClassName" tests/index.spec.tsxLength of output: 48 请更新类名属性和相关测试用例
aojunhao123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** @deprecated Use `placement` instead */ | ||
| popupPlacement?: Placement; | ||
| placement?: Placement; | ||
| builtinPlacements?: BuildInPlacements; | ||
|
|
||
|
|
@@ -131,8 +127,8 @@ export type ValueType< | |
| ValueField extends keyof OptionType = keyof OptionType, | ||
| > = keyof OptionType extends ValueField | ||
| ? unknown extends OptionType['value'] | ||
| ? OptionType[ValueField] | ||
| : OptionType['value'] | ||
| ? OptionType[ValueField] | ||
| : OptionType['value'] | ||
| : OptionType[ValueField]; | ||
|
|
||
| export type GetValueType< | ||
|
|
@@ -201,18 +197,16 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | |
|
|
||
| // Options | ||
| options, | ||
| dropdownPrefixCls, | ||
| popupPrefixCls, | ||
| loadData, | ||
|
|
||
| // Open | ||
| popupVisible, | ||
| open, | ||
|
|
||
| popupClassName, | ||
| dropdownMenuColumnStyle, | ||
| popupMenuColumnStyle, | ||
| popupStyle: customPopupStyle, | ||
|
|
||
| popupPlacement, | ||
| placement, | ||
|
|
||
| onPopupVisibleChange, | ||
|
|
@@ -272,7 +266,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | |
| mergedSearchValue, | ||
| mergedOptions, | ||
| mergedFieldNames, | ||
| dropdownPrefixCls || prefixCls, | ||
| popupPrefixCls || prefixCls, | ||
| searchConfig, | ||
| changeOnSelect || multiple, | ||
| ); | ||
|
|
@@ -365,19 +359,14 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | |
| onInternalSelect(valueCells); | ||
| }; | ||
|
|
||
| // ============================ Open ============================ | ||
| const mergedOpen = open !== undefined ? open : popupVisible; | ||
|
|
||
|
|
||
| const mergedPlacement = placement || popupPlacement; | ||
|
|
||
| const onInternalPopupVisibleChange = (nextVisible: boolean) => { | ||
| onPopupVisibleChange?.(nextVisible); | ||
| }; | ||
|
|
||
| const mergedPopupMenuColumnStyle = popupMenuColumnStyle || dropdownMenuColumnStyle; | ||
|
|
||
| // ========================== Warning =========================== | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| warningProps(props); | ||
| warningNullOptions(mergedOptions, mergedFieldNames); | ||
| } | ||
|
|
||
|
|
@@ -392,12 +381,12 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | |
| onSelect: onInternalSelect, | ||
| checkable, | ||
| searchOptions, | ||
| dropdownPrefixCls, | ||
| popupPrefixCls, | ||
| loadData, | ||
| expandTrigger, | ||
| expandIcon, | ||
| loadingIcon, | ||
| dropdownMenuColumnStyle, | ||
| popupMenuColumnStyle: mergedPopupMenuColumnStyle, | ||
| optionRender, | ||
| }), | ||
| [ | ||
|
|
@@ -409,12 +398,12 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | |
| onInternalSelect, | ||
| checkable, | ||
| searchOptions, | ||
| dropdownPrefixCls, | ||
| popupPrefixCls, | ||
| loadData, | ||
| expandTrigger, | ||
| expandIcon, | ||
| loadingIcon, | ||
| dropdownMenuColumnStyle, | ||
| mergedPopupMenuColumnStyle, | ||
| optionRender, | ||
| ], | ||
| ); | ||
|
|
@@ -427,12 +416,12 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | |
| const popupStyle: React.CSSProperties = | ||
| // Search to match width | ||
| (mergedSearchValue && searchConfig.matchInputWidth) || | ||
| // Empty keep the width | ||
| emptyOptions | ||
| // Empty keep the width | ||
| emptyOptions | ||
| ? {} | ||
| : { | ||
| minWidth: 'auto', | ||
| }; | ||
| minWidth: 'auto', | ||
| }; | ||
|
|
||
| return ( | ||
| <CascaderContext.Provider value={cascaderContext}> | ||
|
|
@@ -460,9 +449,9 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re | |
| OptionList={OptionList} | ||
| emptyOptions={emptyOptions} | ||
| // Open | ||
| open={mergedOpen} | ||
| open={open} | ||
| popupClassName={popupClassName} | ||
| placement={mergedPlacement} | ||
| placement={placement} | ||
| onPopupVisibleChange={onInternalPopupVisibleChange} | ||
| // Children | ||
| getRawInputElement={() => children as React.ReactElement} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -514,28 +514,20 @@ describe('Cascader.Basic', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(wrapper.isOpen()).toBeTruthy(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('warning popupVisible & onPopupVisibleChange & popupClassName', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('warning onPopupVisibleChange & popupClassName', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
aojunhao123 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| resetWarned(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const onPopupVisibleChange = jest.fn(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const wrapper = mount( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Cascader | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| popupVisible | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| open | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onPopupVisibleChange={onPopupVisibleChange} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| popupClassName="legacy-cls" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| popupPlacement="topRight" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| placement="topRight" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| />, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('warning onPopupVisibleChange & popupClassName', () => { | |
| resetWarned(); | |
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | |
| const onPopupVisibleChange = jest.fn(); | |
| const wrapper = mount( | |
| <Cascader | |
| popupVisible | |
| open | |
| onPopupVisibleChange={onPopupVisibleChange} | |
| popupClassName="legacy-cls" | |
| popupPlacement="topRight" | |
| placement="topRight" | |
| />, | |
| it('warning onDropdownVisibleChange & dropdownClassName', () => { | |
| resetWarned(); | |
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | |
| const onPopupVisibleChange = jest.fn(); | |
| const wrapper = mount( | |
| <Cascader | |
| open | |
| onDropdownVisibleChange={onPopupVisibleChange} | |
| dropdownClassName="legacy-cls" | |
| placement="topRight" | |
| />, | |
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
事件处理器更新不完整
根据 PR 的目标是废弃旧 API,
onPopupVisibleChange也应该更新为新的 API 名称。🏁 Script executed:
Length of output: 267
请更新所有事件处理器引用
根据最新的检查,在
examples/visible.tsx(第 75 行)以及src/Cascader.tsx中(例如第 109、212、363 和 455 行)的代码依然使用了旧 APIonPopupVisibleChange。而本次 PR 的目标是废弃旧 API,因此需要将所有相关引用统一更新为新版 APIonDropdownVisibleChange。示例修改差异:
请同步检查并更新
src/Cascader.tsx中所有涉及该事件处理器的位置,以确保整个代码库的一致性。📝 Committable suggestion