Skip to content

Commit 8c8efc7

Browse files
authored
Merge pull request #523 from gautamdsheth/comboboxFix
Fix: comboBoxListItemPicker onSelectedItem callback fix
2 parents 69a6eab + 4e74520 commit 8c8efc7

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/controls/listItemPicker/ComboBoxListItemPicker.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,26 @@ export class ComboBoxListItemPicker extends React.Component<IComboBoxListItemPic
104104
/**
105105
* On Selected Item
106106
*/
107-
private onChanged = (option?: IComboBoxOption, index?: number, value?: string, submitPendingValueEvent?: any): void => {
108-
if (option && option.selected) {
107+
private onChanged = (option?: IComboBoxOption, index?: number, value?: string, submitPendingValueEvent?: any): void => {
108+
if(this.props.multiSelect){
109+
if (option && option.selected) {
110+
this.selectedItems.push({
111+
[this.props.keyColumnInternalName || "Id"]: option.key,
112+
[this.props.columnInternalName]: option.text,
113+
selected: option.selected
114+
});
115+
} else {
116+
this.selectedItems = this.selectedItems.filter(o => o[this.props.keyColumnInternalName || "Id"] !== option.key);
117+
}
118+
}else{
109119
this.selectedItems.push({
110120
[this.props.keyColumnInternalName || "Id"]: option.key,
111-
[this.props.columnInternalName]: option.text,
112-
selected: option.selected
121+
[this.props.columnInternalName]: option.text
113122
});
114-
} else {
115-
this.selectedItems = this.selectedItems.filter(o => o[this.props.keyColumnInternalName || "Id"] !== option.key);
123+
124+
this.selectedItems = this.selectedItems.filter(o => o[this.props.keyColumnInternalName || "Id"] === option.key);
116125
}
117-
this.props.onSelectedItem(this.selectedItems.map(item => ({
118-
[this.props.keyColumnInternalName || "Id"]: item.key,
119-
[this.props.columnInternalName]: item.text
120-
})));
126+
127+
this.props.onSelectedItem(this.selectedItems);
121128
}
122129
}

src/controls/listView/ListView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as strings from 'ControlStrings';
88
import { IGroupsItems } from './IListView';
99
import * as telemetry from '../../common/telemetry';
1010
import { TextField } from 'office-ui-fabric-react/lib/components/TextField';
11-
import { filter } from 'lodash';
11+
import filter = require('lodash/filter');
1212

1313
/**
1414
* File type icon component

0 commit comments

Comments
 (0)