Created attachment 8875550 [details] Page with a date field and another one in a frame Steps to reproduce: 1. Click a date input outside the frame 2. Click a date input inside the frame 3. Click a date input outside the frame 4. Click a date input inside the frame Expected behaviour: Date chooser will open. Actual behaviour: Date chooser is not opened. Frames are commonly used by jsfiddle where I first noticed this. There are actually many variations on the bug, looks like state management gone wrong.
[triage] basic function not working. P1.
Priority: -- → P1
I found that this is because we check document.activeElement on blur event handler , and if document.activeElement is still the input element, we do nothing and early return. If date input is inside an iframe, when you click outside the iframe, the iframe and the input element is no longer focused, but document.activeElement inside the iframe is still the input element, hence we early return and the state of the picker is wrong after that. I think we may need to extra check if the input is inside an iframe and if the iframe has focus or not. Or maybe we can just remove this part , since it looks like it's not possible to call .focus() on blur event handler. Olli, what do you think?  http://searchfox.org/mozilla-central/rev/61054508641ee76f9c49bcf7303ef3cfb6b410d2/toolkit/content/widgets/datetimebox.xml#1612-1613
Hmm, how do we prevent calling .focus() in while handling blur, but looks like that is somehow happening data:text/html,<input id="a" onblur="this.nextSibling.focus();" placeholder="Focus me"><input id="b" onfocus="this.previousSibling.focus();"><input id="c" placeholder="and then click me"> But I think I could live without the activeElement check after all.
I'd still like to understand what prevents re-focusing in blur. I couldn't immediately see it
We prevent re-focusing in blur here . However, focusing another element is valid, data:text/html,<input id="a" onblur="this.nextSibling.focus();" placeholder="Focus me"><input id="b" onfocus="this.previousSibling.focus();"><input id="c" placeholder="and then click me"> so in this case, focusing "a" and then clicking "c", I get: focus a blur a focus b blur b focus c  http://searchfox.org/mozilla-central/rev/d67ef71097da4d1aa344c9d9c672e49a7228e765/dom/base/nsFocusManager.cpp#1817-1818
Created attachment 8877493 [details] [diff] [review] patch, v1.
Attachment #8877493 - Flags: review?(bugs)
Pushed by firstname.lastname@example.org: https://hg.mozilla.org/integration/mozilla-inbound/rev/7537cb5329c4 [DateTimeInput] Remove activeElement check in blur event handler. r=smaug
Status: UNCONFIRMED → RESOLVED
Last Resolved: a year ago
status-firefox56: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Verified as fixed using the latest Nightly 56.0a1 (2017-07-09) on Ubuntu 16.04, Mac OS X 10.12 and Windows 10 x64.
Status: RESOLVED → VERIFIED
status-firefox56: fixed → verified
You need to log in before you can comment on or make changes to this bug.