<input type=number> should not fire extra focus/blur events when script focuses it immediately after inserting it into the document or making it visible by removing display:none
Categories
(Core :: DOM: Core & HTML, defect, P3)
Tracking
()
People
(Reporter: obrufau, Assigned: mbrodesser)
References
Details
Attachments
(2 files)
Comment 1•10 years ago
|
||
Comment 2•10 years ago
|
||
Comment 3•10 years ago
|
||
Comment 4•10 years ago
|
||
Comment 5•10 years ago
|
||
Comment 7•10 years ago
|
||
Comment 8•10 years ago
|
||
Updated•10 years ago
|
Comment 10•9 years ago
|
||
Updated•7 years ago
|
Comment 13•7 years ago
|
||
Comment 14•6 years ago
|
||
I tested this with the latest FF Nightly 67.0a1(2019-03-12) on Windows 10 and Mac OS X 10.14 and I can't reproduce the issue, the input type from the attachment is focused.
obrufau, can you please retest this with the latest Nightly? You can download it from here: https://www.mozilla.org/en-US/firefox/nightly/all/
Comment 15•6 years ago
|
||
I can reproduce with the latest Nightly (2019-03-16 124ee436c421) on Windows 10 1803.
You need to open the console and load the attachment, then you will see the blur event:
Blur
Focus
In Chromium I only get
Focus
Comment 16•6 years ago
|
||
Hi Oriol,
I've compared Nightly with Chromium and in both cases, I have the same result. Bur Focus. Please see this print screen: https://imgur.com/a/nhQGPXW
Comment 17•6 years ago
|
||
Your screenshot shows that in Firefox you are getting a blur event before the focus one, this doesn't happen in Chromium.
Comment 18•6 years ago
•
|
||
Ok, I understand now what is the issue here. Thanks for your help.
I also tested this on Mac OS X 10.14 and the issue is reproducible.
The Release 66 version, Beta 67.0b1and Nightly 68.0a1 (2018-03-18) are affected by this issue, I will update the tracking flags.
Updated•6 years ago
|
Updated•6 years ago
|
Comment 20•6 years ago
|
||
Hi Mirko, while you're on other input issues recently, could you please look at this and relevant see-also ones? Thank you!
| Assignee | ||
Comment 21•6 years ago
|
||
To determine the current state, I've tried the following reproductions:
-
The one in the description:
Most of the time the triggered events are in the following order: blur, blur, focus, focus.
However, sometimes the first blur was missing. -
The one in comment #2:
- Without delay: blur, focus, focus.
- With delay: focus.
| Assignee | ||
Comment 22•6 years ago
•
|
||
When multiple blur and focus events are triggered, the problem seems to be: in HTMLInputElement::Focus the numberControlFrame isn't set (and probably not constructed) yet. The control flow is as follows:
HTMLInputElement::Focus->Element::Focus-> ... ->nsFocusManager::SetFocus->nsFocusManager::SetFocusInner->nsFocusManager::CheckIfFocusable-> ... ->nsIPresShell::FlushPendingNotifications-> ... ->nsCSSFrameConstructor::ConstructFrameFromItemInternal->nsCSSFrameConstructor::ProcessChildren->nsCSSFrameConstructor::GetAnonymousContent->nsNumberControlFrame::CreateAnonymousContent.
When exactly one focus event is triggered, that frame always seems to be set. This can be achieved when delaying the call to focus after the input element has been attached to the DOM (as described in comment #2). In that case:
nsRefreshDriver::Tick->nsIPresShell::FlushPendingNotifications-> ... ->nsCSSFrameConstructor::ConstructFrameFromItemInternal-> ... ->nsNumberControlFrame::CreateAnonymousContentcreates the anonymous content.- The number control frame seems to be set somewhere in
nsCSSFrameConstructortoo. - When
HTMLInputElement::Focusis called, it can properly focus the text control of the<input type="number">.
| Assignee | ||
Updated•6 years ago
|
| Assignee | ||
Comment 23•6 years ago
|
||
-
Avoids undesired bluring and focusing of '<input type="number">' and its nested elements.
-
Add tests for two scenarios where this could occur.
| Assignee | ||
Comment 24•6 years ago
|
||
A try run corresponding to the review. The few failures are not related to this change. Requesting check-in.
| Assignee | ||
Updated•6 years ago
|
Comment 25•6 years ago
|
||
Pushed by nbeleuzu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ee8e96e5d015
ensure all frames for '<input type="number">' are created before choosing the nested element to be focused. r=smaug
Comment 26•6 years ago
|
||
| bugherder | ||
Updated•6 years ago
|
Updated•6 years ago
|
Description
•