Summary: | javascript .select() method doesn't work from onfocus | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Anantha Keesara <anantha> | ||||
Component: | Forms | Assignee: | Nobody <webkit-unassigned> | ||||
Status: | NEW --- | ||||||
Severity: | Normal | CC: | ahmad.saleem792, ap, a.renevier, bfulgham, bugz, cdumez, ivan, priyajeet.hora, rniwa, venkat.koduru | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | All | ||||||
OS: | macOS 12 | ||||||
URL: | http://www.java2s.com/Code/JavaScriptDemo/SelectingTextUponFocus.htm | ||||||
Attachments: |
|
Description
Anantha Keesara
2008-12-05 12:50:24 PST
Created attachment 25784 [details]
reduction
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? 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. *** Bug 23710 has been marked as a duplicate of this bug. *** 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? 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". 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 |