                                                                                  email (get-email user)]
                                                                              (om/build form/text-field
                                                                                        {:on-change (fn [event]
-                                                                                                     (let [input (.. event -target -value)]
-                                                                                                       (set-email! user input)
-                                                                                                       (when (or (and (not is-selected)
-                                                                                                                      (not (empty? input)))
-                                                                                                                 (utils/valid-email? input))
-                                                                                                         (select-user! user))))
+                                                                                                     (let [trimmed-input (gstr/trim (.. event -currentTarget -value))
+                                                                                                           is-valid (valid-email? trimmed-input)]
+                                                                                                       (set-email! user trimmed-input)
+                                                                                                       (cond
+                                                                                                         (and (not is-selected)
+                                                                                                              is-valid)
+                                                                                                         (select-user! user)
+                                                                                                         (and is-selected
+                                                                                                              (not is-valid))
+                                                                                                         (deselect-user! user))))
                                                                                         :value email
                                                                                         :size :medium
                                                                                         :validation-error (when (and (or is-selected
                                                                                                                          (not (empty? email)))
-                                                                                                                     (not (utils/valid-email? email)))
+                                                                                                                     (not (valid-email? email)))
                                                                                                             (str email " is not a valid email"))})))}
                                                                {:type :shrink
                                                                 :cell-fn (fn [user]

            (om/set-state! owner
                           :org-members-by-login
                           (into {}
                                 (for [{:keys [login circle_member email]
                                        :as user} new-vcs-users
                                       :when (not circle_member)]
                                   [login (-> user
                                              (select-keys [:email :login :id])
                                              (assoc :selected (utils/valid-email? email)))]))))))
      
      om/IRenderState
      (render-state [_ {:keys [org-members-by-login]}]

                                                                                                                          :org-name (:name selected-org)}])
                                                                                    (close-fn))
                                                                       :disabled (or (empty? (invitees org-members-by-login))
                                                                                     (not (every? (comp valid-email? :email) (invitees org-members-by-login))))}
                                              "Send Invites "
                                              [:i.fa.fa-envelope-o]])]
                                  :close-fn close-fn}))
