Open Bug 981248 Opened 6 years ago Updated 2 months ago

<input> has focus/blur issues when it has focus and its type changes to/from type=number


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




Webcompat Priority P1
Tracking Status
firefox27 --- unaffected
firefox28 --- affected
firefox29 --- affected
firefox30 --- affected


(Reporter: jchen, Unassigned, NeedInfo)


(Blocks 2 open bugs, )


(Whiteboard: [webcompat:p1])


(3 files)

The first input in the test case switches its type from 'text' to 'number' in its onfocus handler, and switches back in onblur. However, after it switches to number, it no longer accepts any input. This happens because the focus is still on the parent element rather than on the (newly created) anonymous child element.

I think the block at [1] is supposed to fix this problem, but it doesn't actually work because the anonymous child is not bound to the document at that point, so nsFocusManager::SetFocus() fails. SetFocus() wouldn't work in any case, because assuming the anonymous child is focused, the parent input element will get a blur event; during the blur handler, the input type is switched back to text and everything is destroyed; we still don't get a focused number input.

I think we have to make some changes to nsFocusManager to fix this. 

Severity: normal → minor
Priority: -- → P4
See Also: → 1122889
There are other related issues when changing the type. For example, bug 1057858 comment 3.
Summary: Input is not focused when switching input type to number on focus → <input> has focus/blur issues when it has focus and its type changes to/from type=number
See Also: → 1057858
Here is a version with all the current input types:

This confirms that it only occurs with the number type.
This breaks the "Search by flight number" status functionality on's mobile site.

(If I had to guess, sites do this because they want the "number" keypad (on mobile), but not the ugly spinners that they can't turn off.)
Bumping up to P3 because this breaks real sites (not sure anyone uses priority values, but all the same...)
Severity: minor → normal
Priority: P4 → P3
Wasted hours tracking this down. Rather subtle. Reported at where it was blamed on AngularJS.

However here's a demo of it happening with jQuery. The field can only be edited once in Firefox.

Changing an input field from text to number causes the field to spontaneously blur.
See Also: → 1211895
Flags: webcompat+
Whiteboard: [webcompat:p3]
This is quite an annoying issue, as DOM insertion includes changing the type. Our use case is for an INTL currency input:
- By default be input type="text" for INTL currency formatting,
- On focus/click change to input type="number" to benefit from browser number functionality.
- On blur change to input type="text" for INTL currency formatting again.

In Reactive UI programming this is much hit upon problem:

And there appears to be multiple related issues on bugzilla:
Whiteboard: [webcompat:p3] → [webcompat:p2]
I had this WIP patch around, which simplifies a bunch of stuff and should fix this as well, but needs a bit more work.

I didn't want to lose track of it.
Duplicate of this bug: 977259
Whiteboard: [webcompat:p2] → [webcompat:p1]
Priority: P3 → P2

See bug 1547409. Migrating webcompat priority whiteboard tags to project flags.

Webcompat Priority: --- → P1
Attached file wpt.html

I could not find a test like this already in the web platform tests (or the Blink or WebKit test suites), so here is a testharness.js WPT (like uievents/click/auxclick_event.html) which should do the trick.

I had a patch to stop using the hacky anonymous text control for number inputs somewhere in bugzilla, I should probably rescue that patch.

Flags: needinfo?(emilio)

Oh, it was attached to this bug. :-)

I'll try to rebase it.

I have, which kinda works. I just pushed it to try to see where it stands.

Flags: needinfo?(emilio)

(Didn't want to drop the ni?)

Flags: needinfo?(emilio)

So from the try run:

  • Needs some a11y fixes (this should be easy-ish).
  • I broke some font inflation stuff looks like, and need to check the placeholder / preview stuff. I probably need to tweak some reflow bits or some CSS there to make layout correct and consistent.
  • There's an assert that needs investigation. Potentially related to the above.
  • I broke localization of the number but that (a) it is untested (b) it is bogus and (c) no other browser does it.

So all in all seems a bit of work, but probably workable.

Flags: needinfo?(emilio)
Flags: needinfo?(emilio)
Depends on: 1565214

This is also breaking Sunlife's page on Android Firefox browsers, because it causes the on-screen keyboard to never be brought up and users cannot type in their age/etc.

See Also: → 1495482
You need to log in before you can comment on or make changes to this bug.