Open FlowIT-JIT opened 1 year ago
Notice that when onfocusout (or onblur for that matter) fires, focus has not yet been assigned to another element, so document.activeElement will temporarily return <body>
, as the example demonstrates. So if we want to be able to obtain the element soon to be focused, we might need to provide it to the event handlers like demonstrated below.
control.OnBlur(function(sender: Fit.Controls.ControlBase, args: { Target: HTMLElement, Origin: HTMLElement | null }) {});
Basically we just need to forward e.target and e.relatedTarget.
Example improved to prove it respects expected event order when control lose focus: OnMouseDown => Control's OnBlur => OnMouseUp => OnClick https://jsfiddle.net/6qzenLcg/
The OnFocus and OnBlur events fire asynchronously which might cause problems.
Imagine a control having focus, and we push changes to state when OnBlur fires. If we have a Save button which immediately persist state, then it won't persist the latest changes from our control, since OnBlur won't be able to push changes in time to be included in the payload.
We might be able to solve this with an implementation similar to this (IE not supported!):
https://jsfiddle.net/we5c6sqv/9/