@@ -95,6 +95,7 @@ class Select extends Component {
9595 style : { } ,
9696 searchValue : '' ,
9797 isSearch : false ,
98+ hoveredOption : null ,
9899 } ;
99100 this . node = React . createRef ( ) ;
100101 this . optionsNode = React . createRef ( ) ;
@@ -506,6 +507,10 @@ class Select extends Component {
506507 this . setState ( { searchValue : v } ) ;
507508 } ;
508509
510+ onHoverChange = ( item ) => {
511+ this . setState ( { hoveredOption : item } ) ;
512+ } ;
513+
509514 renderOptions ( ) {
510515 const { multiple, confirmTemplate, dataSource } = this . props ;
511516 const { value } = this . state ;
@@ -523,6 +528,8 @@ class Select extends Component {
523528 onSearchValueChange = { this . onSearchValueChange }
524529 handleSelect = { this . handleSelect }
525530 searchValue = { this . state . searchValue }
531+ onHoverChange = { this . onHoverChange }
532+ open = { this . state . open }
526533 />
527534 ) ;
528535 }
@@ -548,6 +555,8 @@ class Select extends Component {
548555 onChange = { this . onSimpleOptionChange }
549556 searchValue = { this . state . searchValue }
550557 onSearchValueChange = { this . onSearchValueChange }
558+ onHoverChange = { this . onHoverChange }
559+ open = { this . state . open }
551560 />
552561 ) ;
553562 }
@@ -567,9 +576,10 @@ class Select extends Component {
567576 supportUnlimited,
568577 formSize,
569578 dataSource,
579+ dropdownConfig,
570580 ...otherProps
571581 } = this . props ;
572- const { selected, open, style : popupStyle } = this . state ;
582+ const { selected, open, style : popupStyle , hoveredOption } = this . state ;
573583 const { width } = this . selectedContainerStyle ;
574584 const classNames = classnames (
575585 `${ selector } ` ,
@@ -581,7 +591,13 @@ class Select extends Component {
581591 < div
582592 className = { `${ selector } -option-container ${ dropdownClassName } ` }
583593 ref = { this . optionsNode }
584- style = { { ...popupStyle , width : `${ width } px` , ...dropdownStyle } }
594+ style = { {
595+ ...popupStyle ,
596+ width : hoveredOption ?. [ this . props . selectInfoKey ]
597+ ? dropdownConfig ?. width
598+ : dropdownConfig ?. leftWidth || dropdownStyle ?. width || `${ width } px` ,
599+ ...dropdownStyle ,
600+ } }
585601 >
586602 { this . renderOptions ( ) }
587603 </ div >
@@ -676,6 +692,8 @@ Select.propTypes = {
676692 selectAllText : PropTypes . string ,
677693 borderRadiusSize : PropTypes . oneOf ( [ 'default' , 'medium' , 'large' ] ) ,
678694 checkboxStyle : PropTypes . object ,
695+ dropdownConfig : PropTypes . object ,
696+ selectInfoKey : PropTypes . string ,
679697} ;
680698
681699Select . defaultProps = {
@@ -726,6 +744,7 @@ Select.defaultProps = {
726744 selectAllText : '全选' ,
727745 borderRadiusSize : 'default' ,
728746 checkboxStyle : { } ,
747+ selectInfoKey : 'selectInfo' ,
729748} ;
730749
731750export default Select ;
0 commit comments