Skip to content

Commit

Permalink
Merge pull request #523 from gautamdsheth/comboboxFix
Browse files Browse the repository at this point in the history
Fix: comboBoxListItemPicker onSelectedItem callback fix
  • Loading branch information
AJIXuMuK authored Apr 28, 2020
2 parents 69a6eab + 4e74520 commit 8c8efc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions src/controls/listItemPicker/ComboBoxListItemPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,26 @@ export class ComboBoxListItemPicker extends React.Component<IComboBoxListItemPic
/**
* On Selected Item
*/
private onChanged = (option?: IComboBoxOption, index?: number, value?: string, submitPendingValueEvent?: any): void => {
if (option && option.selected) {
private onChanged = (option?: IComboBoxOption, index?: number, value?: string, submitPendingValueEvent?: any): void => {
if(this.props.multiSelect){
if (option && option.selected) {
this.selectedItems.push({
[this.props.keyColumnInternalName || "Id"]: option.key,
[this.props.columnInternalName]: option.text,
selected: option.selected
});
} else {
this.selectedItems = this.selectedItems.filter(o => o[this.props.keyColumnInternalName || "Id"] !== option.key);
}
}else{
this.selectedItems.push({
[this.props.keyColumnInternalName || "Id"]: option.key,
[this.props.columnInternalName]: option.text,
selected: option.selected
[this.props.columnInternalName]: option.text
});
} else {
this.selectedItems = this.selectedItems.filter(o => o[this.props.keyColumnInternalName || "Id"] !== option.key);
this.selectedItems = this.selectedItems.filter(o => o[this.props.keyColumnInternalName || "Id"] === option.key);
}
this.props.onSelectedItem(this.selectedItems.map(item => ({
[this.props.keyColumnInternalName || "Id"]: item.key,
[this.props.columnInternalName]: item.text
})));

this.props.onSelectedItem(this.selectedItems);
}
}
2 changes: 1 addition & 1 deletion src/controls/listView/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as strings from 'ControlStrings';
import { IGroupsItems } from './IListView';
import * as telemetry from '../../common/telemetry';
import { TextField } from 'office-ui-fabric-react/lib/components/TextField';
import { filter } from 'lodash';
import filter = require('lodash/filter');

/**
* File type icon component
Expand Down

0 comments on commit 8c8efc7

Please sign in to comment.