W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

Re: Where should UA insert text when the focus is changed in a keypress event handler?

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Tue, 27 Mar 2012 10:58:22 +0200
To: public-webapps <public-webapps@w3.org>, "Ryosuke Niwa" <rniwa@webkit.org>
Cc: "Aryeh Gregor" <ayg@aryeh.name>
Message-ID: <op.wbtm7kjha3v5gv@hr-desk>
Ryosuke Niwa <rniwa@webkit.org> skreiv Tue, 20 Mar 2012 18:54:11 +0100

> We're trying to figure out inside which element the editing operation  
> must
> be done when a keypress event handler changes the focused element /
> selection for https://bugs.webkit.org/show_bug.cgi?id=81661.
> Should it be done at wherever focus is after keypress event is  
> dispatched?
> Or whatever keypress event's target was?

FWIW, Opera does #1 - inserts character in the newly focused input. I  
recall bugs where typing bank account numbers/pin codes and such on pages  
where a script changed focus automatically failing, so I believe that  
compatibility problems has shaped our implementation. This doesn't mean  
we'll never change it again, but it does mean we will thread carefully..

> According to a fellow WebKit contributor, WebKit and Internet Explorer  
> use the current focused element whereas Firefox uses the event target.

This statement is a bit confusing because I have a few tests here where  
Chrome uses the event target.. :-o so it's WebKit and Gecko versus Trident  
and Presto in terms of behaviour.

data:text/html,<input autofocus onkeypress="i2.focus()"><input id="i2">

Typing a character inserts the character in the first input even though  
focus is changing.

Hallvord R. M. Steen
Core tester, Opera Software
Received on Tuesday, 27 March 2012 08:59:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:32 UTC