From 4e74520e494dc3717b9982ddfaa097f1174dddd5 Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Tue, 31 Mar 2020 18:20:04 +0530 Subject: [PATCH] Fix: comboBoxListItemPicker onSelectedItem callback fix , fixed lodash import in listview --- .../listItemPicker/ComboBoxListItemPicker.tsx | 27 ++++++++++++------- src/controls/listView/ListView.tsx | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/controls/listItemPicker/ComboBoxListItemPicker.tsx b/src/controls/listItemPicker/ComboBoxListItemPicker.tsx index 8b16a448c..7bad0e27e 100644 --- a/src/controls/listItemPicker/ComboBoxListItemPicker.tsx +++ b/src/controls/listItemPicker/ComboBoxListItemPicker.tsx @@ -104,19 +104,26 @@ export class ComboBoxListItemPicker extends React.Component { - 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); } } diff --git a/src/controls/listView/ListView.tsx b/src/controls/listView/ListView.tsx index 1a1596890..d8c58ba19 100644 --- a/src/controls/listView/ListView.tsx +++ b/src/controls/listView/ListView.tsx @@ -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