diff --git a/examples/basic.tsx b/examples/basic.tsx index 449f3aab..a0d97993 100644 --- a/examples/basic.tsx +++ b/examples/basic.tsx @@ -387,7 +387,7 @@ class Demo extends React.Component { open style={{ width: 300 }} treeData={gData} - titleRender={node => node.label + 'ok'} + treeTitleRender={node => node.label + 'ok'} /> ); diff --git a/src/OptionList.tsx b/src/OptionList.tsx index 2ee23f47..6c83c982 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -43,7 +43,7 @@ const OptionList: React.RefForwardingComponent = (_, r onSelect, dropdownMatchSelectWidth, treeExpandAction, - titleRender, + treeTitleRender, } = React.useContext(TreeSelectContext); const { @@ -242,7 +242,7 @@ const OptionList: React.RefForwardingComponent = (_, r checkedKeys={mergedCheckedKeys} selectedKeys={!checkable ? checkedKeys : []} defaultExpandAll={treeDefaultExpandAll} - titleRender={titleRender} + titleRender={treeTitleRender} {...treeProps} // Proxy event out onActiveChange={setActiveKey} diff --git a/src/TreeSelect.tsx b/src/TreeSelect.tsx index a2afcf97..5aa841b8 100644 --- a/src/TreeSelect.tsx +++ b/src/TreeSelect.tsx @@ -161,7 +161,7 @@ export interface TreeSelectProps< listItemHeight?: number; listItemScrollOffset?: number; onDropdownVisibleChange?: (open: boolean) => void; - titleRender?: (node: ValueType) => React.ReactNode; + treeTitleRender?: (node: ValueType) => React.ReactNode; // >>> Tree treeLine?: boolean; @@ -238,7 +238,7 @@ const TreeSelect = React.forwardRef((props, ref) showTreeIcon, switcherIcon, treeMotion, - titleRender, + treeTitleRender, ...restProps } = props; @@ -440,7 +440,7 @@ const TreeSelect = React.forwardRef((props, ref) // Back fill with origin label const labeledValues = values.map(val => { const targetItem = rawLabeledValues.find(item => item.value === val); - const label = titleRender ? titleRender(targetItem) : targetItem?.label; + const label = treeTitleRender ? treeTitleRender(targetItem) : targetItem?.label; return { value: val, label, @@ -674,7 +674,7 @@ const TreeSelect = React.forwardRef((props, ref) fieldNames: mergedFieldNames, onSelect: onOptionSelect, treeExpandAction, - titleRender, + treeTitleRender, }), [ virtual, @@ -686,7 +686,7 @@ const TreeSelect = React.forwardRef((props, ref) mergedFieldNames, onOptionSelect, treeExpandAction, - titleRender, + treeTitleRender, ], ); diff --git a/src/TreeSelectContext.ts b/src/TreeSelectContext.ts index f583ff5d..344f71de 100644 --- a/src/TreeSelectContext.ts +++ b/src/TreeSelectContext.ts @@ -12,7 +12,7 @@ export interface TreeSelectContextProps { fieldNames: InternalFieldName; onSelect: OnInternalSelect; treeExpandAction?: ExpandAction; - titleRender?: (node: any) => React.ReactNode; + treeTitleRender?: (node: any) => React.ReactNode; } const TreeSelectContext = React.createContext(null as any); diff --git a/tests/Select.props.spec.js b/tests/Select.props.spec.js index 10d38e65..81ef4fe7 100644 --- a/tests/Select.props.spec.js +++ b/tests/Select.props.spec.js @@ -624,7 +624,7 @@ describe('TreeSelect.props', () => {
node.value} + treeTitleRender={node => node.value} treeData={treeData} />
,