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

OpenDropDown() does not work on DropDown created during OnClick event #170

Closed FlowIT-JIT closed 1 year ago

FlowIT-JIT commented 1 year ago

Please see the following demostration: https://jsfiddle.net/c0jytfkz/

Click the red "synthetic" dropdown control which gets replaced with a real dropdown control. Notice how dd.OpenDropDown() is called in code, but the pulldown menu remains closed.

FlowIT-JIT commented 1 year ago

The problem relates to the following code: https://github.com/Jemt/Fit.UI/blob/11837398058ed6e606a84231c0a4ffd28c2745f4/Controls/DropDown/DropDown.js#L167 The code closes the pulldown menu when a click outside of the control is registered.

image
FlowIT-JIT commented 1 year ago

We could postpone event registration - that will allow for any ongoing event to finish executing - although the use of setTimeout is always a bit ugly. Make sure to add comments explaining why!

Also, make sure to guard against the unlikely event that the control gets disposed while waiting for event registration to occur!

FlowIT-JIT commented 1 year ago

Event registration is now being postponed. It now works as expected - the pulldown menu opens: https://jsfiddle.net/e51zoqvx/