Closed Bug 1371121 Opened 7 years ago Closed 7 years ago

Date chooser breaks when clicking between input in iframe

Categories

(Core :: Layout: Form Controls, defect, P1)

55 Branch
Unspecified
Linux
defect

Tracking

()

VERIFIED FIXED
mozilla56
Tracking Status
firefox56 --- verified

People

(Reporter: jtojnar, Assigned: jessica)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

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 [1], 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 [1], since it looks like it's not possible to call .focus() on blur event handler.

Olli, what do you think?

[1] http://searchfox.org/mozilla-central/rev/61054508641ee76f9c49bcf7303ef3cfb6b410d2/toolkit/content/widgets/datetimebox.xml#1612-1613
Flags: needinfo?(bugs)
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.
Flags: needinfo?(bugs)
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 [1]. 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

[1] http://searchfox.org/mozilla-central/rev/d67ef71097da4d1aa344c9d9c672e49a7228e765/dom/base/nsFocusManager.cpp#1817-1818
Attached patch patch, v1.Splinter Review
Attachment #8877493 - Flags: review?(bugs)
Attachment #8877493 - Flags: review?(bugs) → review+
Assignee: nobody → jjong
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/7537cb5329c4
[DateTimeInput] Remove activeElement check in blur event handler. r=smaug
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/7537cb5329c4
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
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
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: