Skip to content

Commit 444680a

Browse files
authored
fix(Select): optimize controlled highlightKey question, close alibaba-fusion#3795 (alibaba-fusion#3798)
1 parent 51f0208 commit 444680a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/select/base.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ export default class Base extends React.Component {
199199
dataSource: this.setDataSource(this.props),
200200
width: 100,
201201
highlightKey:
202-
'highlightKey' in props ? props.highlightKey : props.defaultHighlightKey || props.defaultValue,
202+
'highlightKey' in props
203+
? props.highlightKey
204+
: props.value || props.defaultHighlightKey || props.defaultValue,
203205
srReader: '',
204206
};
205207

src/select/select.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ class Select extends Base {
270270
Object.assign(state, {
271271
highlightKey: nextProps.highlightKey,
272272
});
273+
} else if ('value' in nextProps && nextProps.value !== prevState.value && nextProps.mode === 'single') {
274+
Object.assign(state, {
275+
highlightKey: nextProps.value,
276+
});
273277
}
274278

275279
if ('searchValue' in nextProps && nextProps.searchValue !== prevState.searchValue) {

0 commit comments

Comments
 (0)