I have a menu that, when it loses focus, needs to generate an update 
message to close the menu. Of course the menu is composed, at the DOM 
level, of several nodes. If I attach a blur or focusout handler at the 
menu's root element, it is fired whenever that particular element loses 
focus, even if one of its descendants gains it.  But in that case I do not 
want to close the menu. There are a few ways to handle this in the DOM, 
perhaps the best of which (as far as I know) is to use a focusout handler 
at the root of the menu that looks to see if the event's relatedTarget is a 
descendant of the root.

In Elm, I can define a Json decoder that will climb the DOM tree, but 
equality isn't defined over Json.Decoder.Value(s) (I think), which suggests 
that the root node would need to be tagged in some way that a Json decoder 
can see. And now we're getting into very hacky territory.

So... is there a better way to accomplish this? (By the way, yes, I really 
do want to know if the menu loses focus, not just if someone has clicked 
outside of it.)

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to