fit-ui 2.16.5 → 2.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Fit.UI.js CHANGED
@@ -682,7 +682,7 @@ Fit._internal =
682
682
  {
683
683
  Core:
684
684
  {
685
- VersionInfo: { Major: 2, Minor: 16, Patch: 5 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
685
+ VersionInfo: { Major: 2, Minor: 16, Patch: 6 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
686
686
  }
687
687
  };
688
688
 
@@ -17332,6 +17332,7 @@ Fit.Controls.DropDown = function(ctlId)
17332
17332
  var searchModeOnFocus = false; // Flag indicating whether control goes into search mode when it is focused (search mode clears input field and displays "search.." placeholder)
17333
17333
  var onScrollElement = null; // Holds control's scroll parent when drop down is open
17334
17334
  var onScrollEventId = -1; // Holds ID of OnScroll event handler registered when drop down is open
17335
+ var cancelEventRegistrationOnOpen = null; // Holds function reference which cancels event registration if no longer needed (related to onScrollElement and onScrollEventId)
17335
17336
 
17336
17337
  var onInputChangedHandlers = []; // Invoked when input value is changed - takes two arguments (sender (this), text value)
17337
17338
  var onPasteHandlers = []; // Invoked when a value is pasted - takes two arguments (sender (this), text value)
@@ -17538,30 +17539,37 @@ Fit.Controls.DropDown = function(ctlId)
17538
17539
 
17539
17540
  me.OnOpen(function()
17540
17541
  {
17541
- postpone(function() // Postpone to avoid auto closing drop down if browser scrolls control into view when it receives focus
17542
+ cancelEventRegistrationOnOpen = postpone(function() // Postpone to avoid auto closing drop down if browser scrolls control into view when it receives focus
17542
17543
  {
17543
- if (me.IsDropDownOpen() === true) // Might have been closed while waiting
17544
- {
17545
- onScrollElement = Fit.Dom.GetScrollParent(me.GetDomElement());
17544
+ cancelEventRegistrationOnOpen = null;
17546
17545
 
17547
- if (onScrollElement === document.documentElement)
17548
- {
17549
- onScrollElement = window;
17550
- }
17546
+ onScrollElement = Fit.Dom.GetScrollParent(me.GetDomElement());
17551
17547
 
17552
- if (onScrollElement !== null)
17548
+ if (onScrollElement === document.documentElement)
17549
+ {
17550
+ onScrollElement = window;
17551
+ }
17552
+
17553
+ if (onScrollElement !== null)
17554
+ {
17555
+ onScrollEventId = Fit.Events.AddHandler(onScrollElement, "scroll", function(e)
17553
17556
  {
17554
- onScrollEventId = Fit.Events.AddHandler(onScrollElement, "scroll", function(e)
17555
- {
17556
- me.CloseDropDown();
17557
- });
17558
- }
17557
+ me.CloseDropDown();
17558
+ });
17559
17559
  }
17560
17560
  });
17561
17561
  });
17562
17562
 
17563
17563
  me.OnClose(function()
17564
17564
  {
17565
+ // Cancel postponed operation in case dropdown is opened and closed multiple times to
17566
+ // avoid multiple OnScroll event registrations (https://github.com/Jemt/Fit.UI/issues/195).
17567
+ if (cancelEventRegistrationOnOpen !== null)
17568
+ {
17569
+ cancelEventRegistrationOnOpen();
17570
+ cancelEventRegistrationOnOpen = null;
17571
+ }
17572
+
17565
17573
  if (onScrollElement !== null)
17566
17574
  {
17567
17575
  Fit.Events.RemoveHandler(onScrollElement, onScrollEventId);
@@ -17900,7 +17908,7 @@ Fit.Controls.DropDown = function(ctlId)
17900
17908
  Fit.Events.RemoveHandler(onScrollElement, onScrollEventId);
17901
17909
  }
17902
17910
 
17903
- me = itemContainer = itemCollection = itemDropZones = arrow = txtPrimary = txtActive = txtEnabled = dropDownMenu = picker = orgSelections = invalidMessage = invalidMessageChanged = initialFocus = maxHeight = prevValue = focusAssigned = closeHandlers = dropZone = isMobile = focusInputOnMobile = detectBoundaries = detectBoundariesRelToViewPort = persistView = highlightFirst = searchModeOnFocus = onScrollElement = onScrollEventId = onInputChangedHandlers = onPasteHandlers = onOpenHandlers = onCloseHandlers = suppressUpdateItemSelectionState = suppressOnItemSelectionChanged = clearTextSelectionOnInputChange = prevTextSelection = textSelectionCallback = cmdToggleTextMode = null;
17911
+ me = itemContainer = itemCollection = itemDropZones = arrow = txtPrimary = txtActive = txtEnabled = dropDownMenu = picker = orgSelections = invalidMessage = invalidMessageChanged = initialFocus = maxHeight = prevValue = focusAssigned = closeHandlers = dropZone = isMobile = focusInputOnMobile = detectBoundaries = detectBoundariesRelToViewPort = persistView = highlightFirst = searchModeOnFocus = onScrollElement = onScrollEventId = cancelEventRegistrationOnOpen = onInputChangedHandlers = onPasteHandlers = onOpenHandlers = onCloseHandlers = suppressUpdateItemSelectionState = suppressOnItemSelectionChanged = clearTextSelectionOnInputChange = prevTextSelection = textSelectionCallback = cmdToggleTextMode = null;
17904
17912
 
17905
17913
  base();
17906
17914
  });
@@ -20341,13 +20349,15 @@ Fit.Controls.DropDown = function(ctlId)
20341
20349
  Fit.Validation.ExpectFunction(cb);
20342
20350
  Fit.Validation.ExpectInteger(timeout, true)
20343
20351
 
20344
- setTimeout(function()
20352
+ var toId = setTimeout(function()
20345
20353
  {
20346
20354
  if (me !== null) // Make sure control has not been disposed
20347
20355
  {
20348
20356
  cb();
20349
20357
  }
20350
20358
  }, timeout || 0);
20359
+
20360
+ return function() { clearTimeout(toId); };
20351
20361
  }
20352
20362
 
20353
20363
  init();