Issue 124583 in chromium: Focus and blur handlers triggered twice when switching tabs

130 views
Skip to first unread message

chro...@googlecode.com

unread,
Apr 22, 2012, 12:28:09 PM4/22/12
to chromi...@chromium.org
Status: Unconfirmed
Owner: ----
Labels: Type-Bug Pri-2 Area-Undefined OS-Windows

New issue 124583 by ameline....@gmail.com: Focus and blur handlers
triggered twice when switching tabs
http://code.google.com/p/chromium/issues/detail?id=124583

Chrome Version : 18.0.1025.162
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
URLs (if applicable) : http://jsbin.com/ubuyux
Other browsers tested:
Safari 5: OK
Firefox 4.x: OK
IE 7/8/9: OK

What steps will reproduce the problem?
1. add a onBlur and/or onFocus event to an input text
2. give focus to the field
3. leave to another tab without and come back

What is the expected result?

The onBlur handler should be called once when we leave the tab, the onFocus
should be called once when we come back to the tab. This is the default
behavior in every browser.

What happens instead?
The onBlur handler has been called twice, then the onFocus has been called
twice too.

Test url: http://jsbin.com/ubuyux

chro...@googlecode.com

unread,
Apr 22, 2012, 12:51:25 PM4/22/12
to chromi...@chromium.org

Comment #1 on issue 124583 by crison...@gmail.com: Focus and blur handlers
http://solucion-0x50206a35.blogspot.com/

AL PARECER EL ERROR SE DEBE, POR LA DESINSTALACION DE PROGRAMAS O
ELIMINACIÓN DE VIRUS QUE TAMBIEN FORMABAN PARTE DE LA UNIDAD FISICA, AQUI
LES DEJO UNA SOLUCION ESPERO LES SIRVA, A MI ME SIRVIO... EL LINK ESTA
PROTEGIDO

http://solucion-0x50206a35.blogspot.com/

chro...@googlecode.com

unread,
Apr 25, 2012, 1:17:21 PM4/25/12
to chromi...@chromium.org

Comment #2 on issue 124583 by ameline....@gmail.com: Focus and blur
handlers triggered twice when switching tabs
http://code.google.com/p/chromium/issues/detail?id=124583

NOTE: clicking on the URL address bar has the same effect as switching to
another tab, it triggers twice the onBlur handler of the element that has
the focus ! This javascript bug is annoying, there is no simple workaround
this (except modifying every focus/blur handlers there might be in the
page...).
Thank you.

chro...@googlecode.com

unread,
Apr 25, 2012, 1:44:21 PM4/25/12
to chromi...@chromium.org

Comment #3 on issue 124583 by ameline....@gmail.com: Focus and blur
handlers triggered twice when switching tabs
http://code.google.com/p/chromium/issues/detail?id=124583

I updated the test URL with instructions, please confirm :
http://jsbin.com/ubuyux/7
Thanks

chro...@googlecode.com

unread,
Apr 30, 2012, 8:34:29 AM4/30/12
to chromi...@chromium.org

Comment #4 on issue 124583 by limpa...@hotmail.com: Focus and blur handlers
this is somewhat annoying, yes...
a simple workaround (with javascript!) would be to have a variable toggle
focus and blur throughout your script.
like this:
http://jsfiddle.net/pQNgb/1/
{i know it's jquery, but that's javascript as well... this is annoying, but
it does the trick}

also this bug has been re-reported here
http://code.google.com/p/chromium/issues/detail?id=117307

I guess it's not a javascript bug though... only a chrome/windows issue.
read: it only occurs with chrome on a windows system, even when only using
the DOM.

chro...@googlecode.com

unread,
Apr 30, 2012, 8:39:30 AM4/30/12
to chromi...@chromium.org

Comment #5 on issue 124583 by limpa...@hotmail.com: Focus and blur handlers
http://jsfiddle.net/dSbpc/3/

chro...@googlecode.com

unread,
Apr 30, 2012, 9:25:04 AM4/30/12
to chromi...@chromium.org

Comment #6 on issue 124583 by ameline....@gmail.com: Focus and blur
handlers triggered twice when switching tabs
http://code.google.com/p/chromium/issues/detail?id=124583

You are right, binding a handler dedicated to this bug before any other
handlers would do the trick. Thanks for the idea ! But I would rather just
have this handler return True if we can proceed or False otherwise (or use
$.preventDefault()), so I would not have to change anything to the rest of
my code.

I hope it will be solved soon because it's a nasty and quite well-hidden
bug, I've been lucky to nail it.

chro...@googlecode.com

unread,
May 3, 2012, 7:15:46 AM5/3/12
to chromi...@chromium.org

Comment #7 on issue 124583 by limpa...@hotmail.com: Focus and blur handlers
well i hope too ^^
another thing you could do would be binding the listeners from one another
on-the-fly like this:
http://jsfiddle.net/pQNgb/5/
or even play with jquery's namespacing.

Anyway, hope this 'll be fixed soon

chro...@googlecode.com

unread,
May 20, 2012, 8:59:16 PM5/20/12
to chromi...@chromium.org
Updates:
Labels: WebKit-Forms

Comment #8 on issue 124583 by tk...@chromium.org: Focus and blur handlers
(No comment was entered for this change.)

chro...@googlecode.com

unread,
Sep 4, 2012, 1:12:47 AM9/4/12
to chromi...@chromium.org
Updates:
Status: Duplicate
Mergedinto: 117307

Comment #9 on issue 124583 by tk...@chromium.org: Focus and blur handlers
Reply all
Reply to author
Forward
0 new messages