fit-ui 2.11.17 → 2.11.18

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: 11, Patch: 17 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
685
+ VersionInfo: { Major: 2, Minor: 11, Patch: 18 } // 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
 
@@ -17044,67 +17044,70 @@ Fit.Controls.DropDown = function(ctlId)
17044
17044
 
17045
17045
  // Make drop down close when user clicks outside of control
17046
17046
 
17047
- if (isMobile === false)
17047
+ postpone(function() // Postpone to prevent drop down from closing if created and auto opened during OnClick/OnTouchStart (https://github.com/Jemt/Fit.UI/issues/170)
17048
17048
  {
17049
- var eventId = Fit.Events.AddHandler(document, "click", function(e)
17049
+ if (isMobile === false)
17050
17050
  {
17051
- var target = Fit.Events.GetTarget(e);
17052
-
17053
- if (target !== document.documentElement && target !== document.body && Fit.Dom.IsRooted(target) === false)
17051
+ var eventId = Fit.Events.AddHandler(document, "click", function(e)
17054
17052
  {
17055
- return; // Do not close DropDown if target no longer exists - this may happen if something is removed within DropDown (e.g. an item in the WSDropDown's action menu)
17056
- }
17053
+ var target = Fit.Events.GetTarget(e);
17057
17054
 
17058
- if (me.IsDropDownOpen() === true && target !== me.GetDomElement() && Fit.Dom.Contained(me.GetDomElement(), target) === false)
17059
- {
17060
- me.CloseDropDown();
17061
- }
17062
- });
17063
- Fit.Array.Add(closeHandlers, eventId);
17064
- }
17065
- else
17066
- {
17067
- // OnClick does not work reliably on mobile (at least not on iOS 9 and 10), so using touch events instead
17068
-
17069
- var coords = null;
17070
- var eventId = -1;
17055
+ if (target !== document.documentElement && target !== document.body && Fit.Dom.IsRooted(target) === false)
17056
+ {
17057
+ return; // Do not close DropDown if target no longer exists - this may happen if something is removed within DropDown (e.g. an item in the WSDropDown's action menu)
17058
+ }
17071
17059
 
17072
- eventId = Fit.Events.AddHandler(document, "touchstart", function(e)
17060
+ if (me.IsDropDownOpen() === true && target !== me.GetDomElement() && Fit.Dom.Contained(me.GetDomElement(), target) === false)
17061
+ {
17062
+ me.CloseDropDown();
17063
+ }
17064
+ });
17065
+ Fit.Array.Add(closeHandlers, eventId);
17066
+ }
17067
+ else
17073
17068
  {
17074
- var target = Fit.Events.GetTarget(e);
17069
+ // OnClick does not work reliably on mobile (at least not on iOS 9 and 10), so using touch events instead
17075
17070
 
17076
- coords = null;
17071
+ var coords = null;
17072
+ var eventId = -1;
17077
17073
 
17078
- if (target !== document.documentElement && target !== document.body && Fit.Dom.IsRooted(target) === false)
17074
+ eventId = Fit.Events.AddHandler(document, "touchstart", function(e)
17079
17075
  {
17080
- return; // Do not close DropDown if target no longer exists - this may happen if something is removed within DropDown (e.g. an item in the WSDropDown's action menu)
17081
- }
17076
+ var target = Fit.Events.GetTarget(e);
17082
17077
 
17083
- if (me.IsDropDownOpen() === true && target !== me.GetDomElement() && Fit.Dom.Contained(me.GetDomElement(), target) === false)
17084
- {
17085
- coords = Fit.Events.GetPointerState().Coordinates.Document;
17086
- }
17087
- });
17088
- Fit.Array.Add(closeHandlers, eventId);
17078
+ coords = null;
17089
17079
 
17090
- eventId = Fit.Events.AddHandler(document, "touchend", function(e)
17091
- {
17092
- if (coords === null)
17093
- return;
17094
-
17095
- // Determine whether user moved finger (e.g. to scroll page) in which case we do not want to close the menu
17080
+ if (target !== document.documentElement && target !== document.body && Fit.Dom.IsRooted(target) === false)
17081
+ {
17082
+ return; // Do not close DropDown if target no longer exists - this may happen if something is removed within DropDown (e.g. an item in the WSDropDown's action menu)
17083
+ }
17096
17084
 
17097
- var curCoords = Fit.Events.GetPointerState().Coordinates.Document;
17098
- var moved = (Math.abs(coords.X - curCoords.X) > 10 || Math.abs(coords.Y - curCoords.Y) > 10); // Must be moved at least 10px left/right or up/down
17085
+ if (me.IsDropDownOpen() === true && target !== me.GetDomElement() && Fit.Dom.Contained(me.GetDomElement(), target) === false)
17086
+ {
17087
+ coords = Fit.Events.GetPointerState().Coordinates.Document;
17088
+ }
17089
+ });
17090
+ Fit.Array.Add(closeHandlers, eventId);
17099
17091
 
17100
- if (moved === false)
17092
+ eventId = Fit.Events.AddHandler(document, "touchend", function(e)
17101
17093
  {
17102
- me.CloseDropDown();
17103
- me.Focused(false);
17104
- }
17105
- });
17106
- Fit.Array.Add(closeHandlers, eventId);
17107
- }
17094
+ if (coords === null)
17095
+ return;
17096
+
17097
+ // Determine whether user moved finger (e.g. to scroll page) in which case we do not want to close the menu
17098
+
17099
+ var curCoords = Fit.Events.GetPointerState().Coordinates.Document;
17100
+ var moved = (Math.abs(coords.X - curCoords.X) > 10 || Math.abs(coords.Y - curCoords.Y) > 10); // Must be moved at least 10px left/right or up/down
17101
+
17102
+ if (moved === false)
17103
+ {
17104
+ me.CloseDropDown();
17105
+ me.Focused(false);
17106
+ }
17107
+ });
17108
+ Fit.Array.Add(closeHandlers, eventId);
17109
+ }
17110
+ });
17108
17111
 
17109
17112
  // Make drop down close if focus is lost on mobile
17110
17113
  // which happens when onscreen keyboard is closed.
@@ -17136,7 +17139,7 @@ Fit.Controls.DropDown = function(ctlId)
17136
17139
  if (Fit.Browser.GetBrowser() === "MSIE" || Fit.Browser.GetBrowser() === "Edge")
17137
17140
  {
17138
17141
  txtPrimary.readOnly = false; // ReadOnly set to true to make text-overflow:ellipsis work
17139
- setTimeout(function() { txtPrimary.blur(); txtPrimary.focus(); }, 0); // Change to ReadOnly is not applied immediately unless blurred and re-focused
17142
+ postpone(function() { txtPrimary.blur(); txtPrimary.focus(); }); // Change to ReadOnly is not applied immediately unless blurred and re-focused
17140
17143
  }
17141
17144
 
17142
17145
  clearTextSelectionOnInputChange = true;
@@ -18741,7 +18744,7 @@ Fit.Controls.DropDown = function(ctlId)
18741
18744
  {
18742
18745
  var orgValue = txt.value;
18743
18746
 
18744
- setTimeout(function() // Timeout to queue event to have pasted value available
18747
+ postpone(function() // Timeout to queue event to have pasted value available
18745
18748
  {
18746
18749
  /*if (me.TextSelectionMode() === true && txt.value === prevTextSelection)
18747
18750
  {
@@ -18784,7 +18787,7 @@ Fit.Controls.DropDown = function(ctlId)
18784
18787
  prevValue = txt.value;
18785
18788
  }
18786
18789
  }
18787
- }, 0);
18790
+ });
18788
18791
 
18789
18792
  clearTextSelectionOnInputChange = false;
18790
18793
  }
@@ -19879,6 +19882,20 @@ Fit.Controls.DropDown = function(ctlId)
19879
19882
  picker._internal.FireOnHide();
19880
19883
  }
19881
19884
 
19885
+ function postpone(cb, timeout)
19886
+ {
19887
+ Fit.Validation.ExpectFunction(cb);
19888
+ Fit.Validation.ExpectInteger(timeout, true)
19889
+
19890
+ setTimeout(function()
19891
+ {
19892
+ if (me !== null) // Make sure control has not been disposed
19893
+ {
19894
+ cb();
19895
+ }
19896
+ }, timeout || 0);
19897
+ }
19898
+
19882
19899
  init();
19883
19900
  }
19884
19901