From a670211bac7fdb26d4fda22548b10547433e29f2 Mon Sep 17 00:00:00 2001
From: vitalets <noginsk@rambler.ru>
Date: Sun, 7 Apr 2013 19:21:53 +0400
Subject: [PATCH] fix #199 - workaround for extra click event in FF 20

---
 src/containers/editable-container.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/containers/editable-container.js b/src/containers/editable-container.js
index 7f52288..cf2798e 100644
--- a/src/containers/editable-container.js
+++ b/src/containers/editable-container.js
@@ -56,7 +56,6 @@ Applied as jQuery method.
                                            '.modal-backdrop', 
                                            '.bootstrap-wysihtml5-insert-image-modal', 
                                            '.bootstrap-wysihtml5-insert-link-modal'
-                                         //  '.select2-drop'
                                            ];
                     
                     //if click inside one of exclude classes --> no nothing
@@ -65,6 +64,13 @@ Applied as jQuery method.
                              return;
                          }
                     }
+                    
+                    //for some reason FF 20 generates extra event (click) in select2 widget with e.target = document
+                    //we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199
+                    //Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec
+                    if($target.is(document)) {
+                       return; 
+                    }
                       
                     //close all open containers (except one - target)
                     Popup.prototype.closeOthers(e.target);