From 8dde651ded58a28d29dfc75c2856450c3a9b5be1 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Wed, 29 Mar 2017 11:07:10 -0400
Subject: Remove user from list when selected in DM modal (#5884)

---
 webapp/components/multiselect/multiselect.jsx | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'webapp/components/multiselect/multiselect.jsx')

diff --git a/webapp/components/multiselect/multiselect.jsx b/webapp/components/multiselect/multiselect.jsx
index a3e32dccf..f6d6b5d56 100644
--- a/webapp/components/multiselect/multiselect.jsx
+++ b/webapp/components/multiselect/multiselect.jsx
@@ -111,7 +111,8 @@ export default class MultiSelect extends React.Component {
     }
 
     render() {
-        const options = this.props.options;
+        const options = Object.assign([], this.props.options);
+        const values = this.props.values;
 
         let numRemainingText;
         if (this.props.numRemainingText) {
@@ -142,6 +143,17 @@ export default class MultiSelect extends React.Component {
             );
         }
 
+        const valueMap = {};
+        for (let i = 0; i < values.length; i++) {
+            valueMap[values[i].id] = true;
+        }
+
+        for (let i = options.length - 1; i >= 0; i--) {
+            if (valueMap[options[i].id]) {
+                options.splice(i, 1);
+            }
+        }
+
         if (options && options.length > this.props.perPage) {
             const pageStart = this.state.page * this.props.perPage;
             const pageEnd = pageStart + this.props.perPage;
-- 
cgit v1.2.3-1-g7c22

