Feel free to edit the question title if you find something better.
I am writing a little plugin for my website,
var main = document.getElementById("main"),
fakeInput = document.getElementById("fakeInput"),
zone = document.getElementById("zone"),
input = document.getElementById("input");
main.addEventListener("focusin", function() {
zone.style.display = "block";
});
main.addEventListener("focusout", function() {
zone.style.display = "none";
});
#main {
width: 200px;
}
#fakeInput {
background: blue;
height: 22px;
}
#zone {
background-color: red;
height: 100px;
text-align: center;
}
click in the blue zone :<br>
<div id="main" tabindex="-1">
<div id="fakeInput"></div>
<div id="zone" style="display:none">
<p>Click in the input :</p>
<input id="input" type="text" />
</div>
</div>
when I click on it, it opens (great !). I can click (almost) anywhere, the "focusout" event is not triggered. Almost, because the input child steal the focus to its parent.
I read here : http://www.quirksmode.org/dom/events/blurfocus.html
focusin and focusout
Fire at the same time as focus and blur, but bubble
In my example, It seems that the focusin event of the input field never reach its parent.
I am looking for a way to fix this, any hints ?