Skip to content

Commit a15b352

Browse files
authored
adjust order (#412)
1 parent 24bf6c7 commit a15b352

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Select.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class Select extends React.Component<Partial<ISelectProps>, ISelectState> {
442442
const props = this.props;
443443
const selectedValue = getValuePropValue(item);
444444
const lastValue = value[value.length - 1];
445-
this.fireSelect(selectedValue);
445+
446446
if (isMultipleOrTags(props)) {
447447
if (findIndexInValueBySingleValue(value, selectedValue) !== -1) {
448448
return;
@@ -463,6 +463,7 @@ class Select extends React.Component<Partial<ISelectProps>, ISelectState> {
463463
}
464464

465465
this.fireChange(value);
466+
this.fireSelect(selectedValue);
466467
const inputValue = isCombobox(props) ? getPropValue(item, props.optionLabelProp) : '';
467468

468469
if (props.autoClearSearchValue) {

tests/Select.spec.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,13 @@ describe('Select', () => {
894894
});
895895

896896
it('backfill', () => {
897-
const handleChange = jest.fn();
898-
const handleSelect = jest.fn();
897+
const triggerQueue: string[] = [];
898+
const handleChange = jest.fn(() => {
899+
triggerQueue.push('change');
900+
});
901+
const handleSelect = jest.fn(() => {
902+
triggerQueue.push('select');
903+
});
899904
const wrapper = mount<Select>(
900905
<Select
901906
backfill={true}
@@ -924,6 +929,8 @@ describe('Select', () => {
924929
expect(handleChange).toBeCalledWith('2', expect.anything());
925930
expect(handleSelect).toBeCalledWith('2', expect.anything());
926931
expect(wrapper.find('.rc-select-selection-selected-value').text()).toEqual('Two');
932+
933+
expect(triggerQueue).toEqual(['change', 'select']);
927934
});
928935

929936
describe('number value', () => {

0 commit comments

Comments
 (0)