Bug 142445 - [test case] selectionStart returns wrong value for input tags with type="text"
Summary: [test case] selectionStart returns wrong value for input tags with type="text"
Status: CONFIRMED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: 4.5.4
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-03 10:36 UTC by Christian Spitzlay
Modified: 2021-03-21 00:25 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Test case to demonstrate the problem (623 bytes, text/html)
2007-03-03 10:38 UTC, Christian Spitzlay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Spitzlay 2007-03-03 10:36:27 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Ubuntu Packages
OS:                Linux

I came across a problem with the selection when selecting text inside a <input type="text"> field (in textareas it works correctly). 

In the case of type="text" the returned value is always equal to the *end* value of the selection (selectionStart and selectionEnd return the same value).  

Please try the attached test case.  There are six letters, a-f.  If I select the letters "cd" from left to right I get "Start 4, End 4", if I select from right to left I get "Start: 2, End: 2".  

For the textarea I get "Start: 2, End: 4" for both directions, as I would expect.  


For comparison: 
Firefox returns "Start: 2, End: 4" for both directions and both fields.
Comment 1 Christian Spitzlay 2007-03-03 10:38:07 UTC
Created attachment 19869 [details]
Test case to demonstrate the problem
Comment 2 Christian Spitzlay 2007-04-06 01:18:46 UTC
- In trunk the problem is there, too. 

- The problem seems to be that w->hasSelectedText() returns false in
RenderLineEdit::selectionStart() and RenderLineEdit::selectionEnd()
even though text is selected.  
Comment 3 Maksim Orlovich 2007-04-21 19:18:59 UTC
Can confirm. Makes me wonder how the heck I tested that when implementing it..
Comment 4 Maksim Orlovich 2007-04-21 20:10:28 UTC
Hmm, what's the source of your Qt? Distro packages, or?
Comment 5 Maksim Orlovich 2007-04-21 20:16:45 UTC
Never mind that. I think what it's reporting is accurate, since when you click elsewhere, the lineedit loses focus, and with it selection (not sure -why- it does that yet). It probably "worked" for me before because the focus handling was buggy.
Comment 6 Maksim Orlovich 2007-04-21 20:27:29 UTC
void QLineEdit::focusOutEvent( QFocusEvent* )
{
    if ( QFocusEvent::reason() != QFocusEvent::ActiveWindow &&
	 QFocusEvent::reason() != QFocusEvent::Popup )
	deselect();


... This may be tricky, since the behavior depends on the ordering of events, and we have to be very aggressive about delivering focus events to widgets, since otherwise Qt can get pretty confused...

Comment 7 Christian Spitzlay 2007-04-22 01:56:30 UTC
Unfortunately what you've written in #6 is way above my head... 
I hope it wasn't meant for me. :)

-----

For the sake of completeness, here are the data: 

Compiled from svn on a Debian unstable: 
$ konqueror -v
Qt: 4.3.0beta
KDE: 3.80.3 (>= 20070220)
Konqueror: 3.80.3

and stock binary packages on Kubuntu (feisty):
$ konqueror -v
Qt: 3.3.7
KDE: 3.5.6
Konqueror: 3.5.6

I see the problem on both.

Comment 8 Christophe Marin 2008-04-20 22:47:33 UTC
This issue still exists in kde4 trunk (r.799086).

Comment 9 FiNeX 2010-09-19 18:00:01 UTC
Bug still valid with KDE 4.4.5 and 4.5.1
Comment 10 Samuel Brack 2011-01-09 22:58:59 UTC
Confirmed in 4.5.4, updating version.
Comment 11 Justin Zobel 2021-03-21 00:25:37 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 10 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.