1- import React , { Children , isValidElement , cloneElement , useRef , CSSProperties , useMemo } from 'react' ;
1+ import React , { Children , cloneElement , isValidElement , useMemo , useRef } from 'react' ;
2+
23import classNames from 'classnames' ;
34import { isEqual } from 'lodash-es' ;
5+
6+ import useConfig from '../../hooks/useConfig' ;
47import { useLocaleReceiver } from '../../locale/LocalReceiver' ;
8+ import usePanelVirtualScroll from '../hooks/usePanelVirtualScroll' ;
59import { getSelectValueArr } from '../util/helper' ;
6- import {
7- TdSelectProps ,
8- SelectValue ,
9- TdOptionProps ,
10- SelectValueChangeTrigger ,
10+ import Option , { type SelectOptionProps } from './Option' ;
11+ import OptionGroup from './OptionGroup' ;
12+
13+ import type {
1114 SelectOption ,
1215 SelectOptionGroup ,
16+ SelectValue ,
17+ SelectValueChangeTrigger ,
18+ TdOptionProps ,
19+ TdSelectProps ,
1320} from '../type' ;
14- import useConfig from '../../hooks/useConfig' ;
15- import usePanelVirtualScroll from '../hooks/usePanelVirtualScroll' ;
16- import Option , { SelectOptionProps } from './Option' ;
17- import OptionGroup from './OptionGroup' ;
1821
1922interface SelectPopupProps
2023 extends Pick <
@@ -171,7 +174,10 @@ const PopupContent = React.forwardRef<HTMLDivElement, SelectPopupProps>((props,
171174 ) ;
172175 }
173176
174- const { value : optionValue , label, disabled, content, children, ...restData } = item as TdOptionProps ;
177+ const { value : optionValue , label, disabled, children, ...restData } = item as TdOptionProps ;
178+ // 当 keys 属性配置 content 作为 value 或 label 时,确保 restData 中也包含它, 不参与渲染计算
179+ const { content } = item as TdOptionProps ;
180+ const shouldOmitContent = Object . values ( keys || { } ) . includes ( 'content' ) ;
175181 return (
176182 < Option
177183 key = { index }
@@ -186,7 +192,6 @@ const PopupContent = React.forwardRef<HTMLDivElement, SelectPopupProps>((props,
186192 disabled = { disabled }
187193 restData = { restData }
188194 keys = { keys }
189- content = { content }
190195 onCheckAllChange = { onCheckAllChange }
191196 onRowMounted = { handleRowMounted }
192197 { ...( isVirtual
@@ -197,6 +202,7 @@ const PopupContent = React.forwardRef<HTMLDivElement, SelectPopupProps>((props,
197202 }
198203 : { } ) }
199204 { ...restData }
205+ content = { shouldOmitContent ? null : content }
200206 >
201207 { children }
202208 </ Option >
@@ -211,7 +217,7 @@ const PopupContent = React.forwardRef<HTMLDivElement, SelectPopupProps>((props,
211217 const isEmpty =
212218 ( Array . isArray ( childrenWithProps ) && ! childrenWithProps . length ) || ( propsOptions && propsOptions . length === 0 ) ;
213219
214- const renderPanel = ( renderedOptions : SelectOption [ ] , extraStyle ?: CSSProperties ) => (
220+ const renderPanel = ( renderedOptions : SelectOption [ ] , extraStyle ?: React . CSSProperties ) => (
215221 < div
216222 ref = { ref }
217223 className = { classNames ( `${ classPrefix } -select__dropdown-inner` , {
0 commit comments