Removed the delay when handling input blur
authorAlexander Ebert <ebert@woltlab.com>
Fri, 1 Feb 2019 23:35:29 +0000 (00:35 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 1 Feb 2019 23:35:29 +0000 (00:35 +0100)
The timeout was required due to a duplication issue caused by the parallel handling of the click event on a suggestion and the blur event as a side effect of the click.

Original change: c75b69cc51639120091243b9c808243a8f747d10

wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js

index 638fd3e1d003e629b114ae9774634c373328fa9c..fde6aef2429b93075eed62c989a2010c47ab7cf2 100644 (file)
@@ -543,21 +543,19 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'WoltLabSu
                 * @param       {object}        event           event object
                 */
                _blur: function(event) {
-                       var data = _data.get(event.currentTarget.id);
+                       var input = event.currentTarget;
+                       var data = _data.get(input.id);
                        if (data.options.restricted) {
                                // restricted item lists only allow results from the dropdown to be picked
                                return;
                        }
                        
-                       var currentTarget = event.currentTarget;
-                       window.setTimeout(function() {
-                               var value = currentTarget.value.trim();
-                               if (value.length) {
-                                       if (!data.suggestion || !data.suggestion.isActive()) {
-                                               this._addItem(currentTarget.id, { objectId: 0, value: value });
-                                       }
+                       var value = input.value.trim();
+                       if (value.length) {
+                               if (!data.suggestion || !data.suggestion.isActive()) {
+                                       this._addItem(input.id, { objectId: 0, value: value });
                                }
-                       }.bind(this), 100);
+                       }
                }
        };
 });