Skip to content

Commit

Permalink
Only toggle item's select status in multiselect (Graylog2#4715)
Browse files Browse the repository at this point in the history
- On a single select, clicking on a selected option will not clear the
  selected item
- On a multiselect, clicking on a selected option will deselect it,
  while keeping the status of other selected items
  • Loading branch information
edmundoa authored and Marius Sturm committed Apr 11, 2018
1 parent eaa1fc4 commit 3822aec
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ const SelectPopover = createReactClass({
return () => {
const selectedItems = this.state.selectedItems;
let nextSelectedItems;
if (selectedItems.includes(item)) {
nextSelectedItems = lodash.without(selectedItems, item);
if (this.props.multiple) {
// Clicking on a selected value on a multiselect input will toggle the item's select status
nextSelectedItems = selectedItems.includes(item) ? lodash.without(selectedItems, item) : lodash.concat(selectedItems, item);
} else {
nextSelectedItems = this.props.multiple ? lodash.concat(selectedItems, item) : [item];
nextSelectedItems = [item];
}
this.handleSelectionChange(nextSelectedItems);
};
Expand Down

0 comments on commit 3822aec

Please sign in to comment.