DEV Community

Discussion on: Elm DOM node decoder to detect click outside

Collapse
 
victor_bezak profile image
Victor Bezak • Edited

Wow, this has been a really great article for me and my team. Our initial solution was to send, onClick, the ids for both our open object and the toggle which opened it (eg. your dropdown, and the button which is responsible for opening/closing it) to Browser.Dom.getElement with Task.attempt, and then store the Maybe (Browser.Element, Browser.Element) response in our model (thus satifsfying our click subscription condition and activating our click listener). From there, when a click event fires we’d compare the event’s pageX and pageY attributes against the x and y attributes from our stored Browser.Element’s, returning a boolean of whether that click was located within the bounds of our stored objects of interest.

I've learned a lot from your solution and we're testing to see whether it's right for our use-case. Thanks again!

p.s. you also put ReasonML on my radar.. very cool