Date chooser breaks when clicking between input in iframe

VERIFIED FIXED in Firefox 56

Status

()

P1
normal
VERIFIED FIXED
a year ago
a year ago

People

(Reporter: jtojnar, Assigned: jessica)

Tracking

(Blocks: 1 bug)

55 Branch
mozilla56
Unspecified
Linux
Points:
---

Firefox Tracking Flags

(firefox56 verified)

Details

Attachments

(2 attachments)

(Reporter)

Description

a year ago
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.
(Reporter)

Updated

a year ago
Blocks: 1323674
[triage]
basic function not working. P1.
Priority: -- → P1
(Assignee)

Comment 2

a year ago
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
(Assignee)

Comment 5

a year ago
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
(Assignee)

Comment 6

a year ago
Created attachment 8877493 [details] [diff] [review]
patch, v1.
Attachment #8877493 - Flags: review?(bugs)

Updated

a year ago
Attachment #8877493 - Flags: review?(bugs) → review+
(Assignee)

Updated

a year ago
Assignee: nobody → jjong

Comment 8

a year ago
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
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.