Jemt / Fit.UI

Fit.UI is a JavaScript based UI framework built on Object Oriented principles
http://fitui.org
GNU Lesser General Public License v3.0
19 stars 7 forks source link

WSDropDown: Reloading TreeView causes Action Menu to disappear #180

Closed FlowIT-JIT closed 1 year ago

FlowIT-JIT commented 1 year ago

See https://jsfiddle.net/nd4bfeyp/8/

var dd;
Fit.Events.OnReady(function() {
  dd = new Fit.Controls.WSDropDown("WSDropDown1");
  dd.Url("https://fitui.org/demo/GetUsers.php?empty=true");
  dd.JsonpCallback("JsonpCallback"); // Loading data from foreign domain
  dd.MultiSelectionMode(true);
  dd.Value("James Thomson=james@server.com;Hans Törp=hans@server.com");
  dd.Width(300);
  dd.DropDownMaxHeight(150);
  dd.InputEnabled(true);
  dd.OnChange(function(sender) {
    doSomethingAsync();
  });
  dd.Render(document.querySelector("#Control"));

  if (Fit.Browser.IsMobile())
    dd.Width(100, "%");
});

function doSomethingAsync() {
  dd.ResetActionMenu(); // Use TreeView again if new data is received
  dd.GetTreeView().Reload(true, function(sender) {
    dd.UpdateActionMenu(); // Make sure Action Menu reflects availability of data
  });
}

Open the DropDown and remove all items using the Action Menu

image

Now close and re-open the DropDown - the informative Action Menu is no longer shown as it normally would when no data is available.

image
FlowIT-JIT commented 1 year ago

The bug relates to the manipulation of TreeView (data is reloaded) obtained via GetTreeView(). The DropDown control does not take external manipulation into account. Maybe it should, or maybe the DropDown control should expose a function allowing for data to be reloaded.

FlowIT-JIT commented 1 year ago

Accommodating every possible change external code can and might do to the picker controls will probably be very difficult. One could argue that GetTreeView() and GetListView should never have exposed the internal pickers, but rather have returned an interface with a limited set of capabilities. For the sake of reliability and predictability, we have merely added a new function that can be used to reload data. This will ensure that the DropDown handles the state of the Action Menu as expected. The updated JSFiddle (running fixed Fit.UI v. 2.12.4) demonstrates that the problem has been resolved using the new ReloadData(..) function: https://jsfiddle.net/ze9Lxuhs/2/

FlowIT-JIT commented 1 year ago

Notice comment regarding commit resolving the problem with "flickering" action menu: https://github.com/Jemt/Fit.UI/commit/55c1a2e2bdff709645a7a3e559c6ccff31bfe422#commitcomment-100093878