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

DropDown.Focused() returns False from DropDown.OnChange in certain case (misuse) #86

Closed FlowIT-JIT closed 4 years ago

FlowIT-JIT commented 4 years ago

Please consider the following excample: https://jsfiddle.net/z1rqwe3n/14/

A Behavioral Node is used to trigger SelectAll on a TreeView that load nodes async. While selecting all nodes, the DropDown is temporarily hidden to reduce reflows (performance consideration - important for large data sets).

Obviously this has the potential to break functionality related to focus, and so it does.

When DropDown.OnChange is fired with the new selection (all nodes selected), DropDown.Focused() returns False.

This is inconsistent with the behavior when SelectAll is triggered without hiding the control, in which case DropDown.Focused() returns True.

Furthermore the problem never arises when the Select All node is triggered using the keyboard (spacebar) since the DropDown remains focused. When the mouse is used to toggle a node, the picker is temporarily focused, but the DropDown "steals" back focus which doesn't work when control is hidden, due to the use of the ProgrammaticallyChanged check here, which is actually based on the control's focused state: https://github.com/Jemt/Fit.UI/blob/d7805253df0f41949eacd7013dc0e03c6ba1d685/Controls/DropDown/DropDown.js#L823

It's unfortunate that we cannot use Focused() to obtain the expected state since hiding the control is essential to achieve decent performance with large data sets.