javascript .select() method doesn't work from onfocus
https://bugs.webkit.org/show_bug.cgi?id=22691
Summary javascript .select() method doesn't work from onfocus
Anantha Keesara
Reported 2008-12-05 12:50:24 PST
Steps: 1. go to the link 2. type some text in 1 of the fields. 3. blur the field, then focus Issue: text doesn't get focused. Other Browsers: FF3, IE7: text gets focused. Nightly tested:WebKit-r38794 Chromium bug: http://code.google.com/p/chromium/issues/detail?id=4505
Attachments
reduction (319 bytes, text/html)
2008-12-05 12:58 PST, Anantha Keesara
no flags
Anantha Keesara
Comment 1 2008-12-05 12:58:26 PST
Created attachment 25784 [details] reduction
Venkat Koduru
Comment 2 2010-02-24 16:46:49 PST
I posted the following message on the code.google page (there's a link in Anantha's comment)... but it's been over a month and this bug doesn't seem to be getting any notice and has not been fixed. So I thought I'd copy my comment here to see if perhaps it'll get more attention. Hope this can help developers to reproduce the bug and fix the issue. It's not a huge bug, but it seems like a significant oversight. I'm having this same exact problem on my website - http://www.upsidedowntext.com/ This is the code: converted.addEvent('focus', function(e) { this.select(); }); converted refers to the bottom textarea box and when focused on, the text inside is supposed to be selected. this works in firefox and ie, but not chrome or safari. so to re-produce the bug, enter text in the top textarea box. then click on the bottom textarea box. you'll notice that the text gets selected, and then de-selected. does anyone know of a quick fix that can be implemented in JavaScript without writing browser-specific code?
Ivan Peters
Comment 3 2010-03-30 14:50:04 PDT
To add some further clarification, the problem only occurs when the field gains the focus via a click. If you tab to the field the content is selected correctly.
Alexey Proskuryakov
Comment 4 2011-04-22 08:58:46 PDT
*** Bug 23710 has been marked as a duplicate of this bug. ***
Terje
Comment 5 2012-11-24 08:21:37 PST
This bug report is over 8 years old, and still no one is fixing it? I am a programmer my self, but before I can contribute may be some of the developers who knows the WebKit code base can help me to find out where to start?
Ahmad Saleem
Comment 6 2022-09-18 03:38:56 PDT
I am able to reproduce this issue in Safari Technology Preview 153 on macOS 12.6 using attached test case. Safari does not select "text" while other browsers (Chrome Canary 108 and Firefox Nightly 106) does. Thanks! Changing to "New".
Ahmad Saleem
Comment 7 2022-09-18 03:47:42 PDT
It could be possible to merge this: https://src.chromium.org/viewvc/blink?view=revision&revision=198752 _____ In EventHandler.cpp: Remove: https://github.com/WebKit/WebKit/blob/2ef8bf040a9db8c0af836f5a92916e087e9b9e16/Source/WebCore/page/EventHandler.cpp#L815 add bit from above here with Comment: https://github.com/WebKit/WebKit/blob/2ef8bf040a9db8c0af836f5a92916e087e9b9e16/Source/WebCore/page/EventHandler.cpp#L1800 ____ In Webkit - I don't think we have SelectionController - so not direct merge possible but could be wrong. ___ In FrameSelection.h - Add "void notifyEventHandlerForSelectionChange();" https://github.com/WebKit/WebKit/blob/6ae0bcb1c73ce6ea808e09557db62a0dbc5446d6/Source/WebCore/editing/FrameSelection.h#L307 In FrameSelection.cpp: No idea where to add - notifyEventHandlerForSelectionChange but for other - it can be added above here: https://github.com/WebKit/WebKit/blob/6ae0bcb1c73ce6ea808e09557db62a0dbc5446d6/Source/WebCore/editing/FrameSelection.cpp#L2138
Note You need to log in before you can comment on or make changes to this bug.