Advertisement:
Anonymous Login
12-07-2016 09:24 AM

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002964SMF 2.0public2010-05-24 18:25
ReporterNao/Gilles 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Summary0002964: [Opera] Cursor not positioned correctly when inserting table or list bbcode (+ reason)
DescriptionUsing Opera 9.63, non-wysiwyg mode.

--------- Reproducing ----------

Write a post.
Click on all icons (all of them).
The error should be obvious.
When there are more than two tags involved, the cursor is not positioned where it should.

- table code: it is placed two characters earlier than expected (right in the first "td" tag).
- normal list and decimal list: it is placed one character earlier than expected (in the first "li" tag).

------- Reason for the bug --------

I think it's pretty safe to say it's because of this: surroundText() positions the cursor according to the first member's length. However, it may contain (as in tables and lists) the '\n' (newline) sequence, which only counts for one character, not too.

"text1.length" should be decreased by the number of times '\n' was found in text1. Or something like that.
Additional Information----------- ADDITIONAL -----------

It may also be interesting to note two things:

- This bug does not seem to happen on Firefox. It may be specific to Opera 9.63.

- I found another place where it happens. When replying to a post, if you click on "quote" next to a message in the message list below the textarea, the message is inserted and the cursor is in a random location near the end. I suppose this is exactly for the same reason (the quoted message has a number of newlines, each of which will make the cursor go back one character in its final position.)
TagsRC3, With Fix
Attached Files
  • txt file icon caretpos fix.txt (681 bytes) 2009-10-31 12:38 -
    script.js
    line 391
    
    Original:
    
    		if (temp_length == 0)
    		{
    			caretPos.moveStart('character', -text2.length);
    			caretPos.moveEnd('character', -text2.length);
    			caretPos.select();
    		}
    		else
    			oTextHandle.focus(caretPos);
    
    Fixed for Opera 9/10:
    
    		if (temp_length == 0)
    		{
    			var goBack = text2.length - (is_opera ? text2.length - text1.match(/\n/g).length : 0);
    			caretPos.moveStart('character', -goBack);
    			caretPos.moveEnd('character', -goBack);
    			caretPos.select();
    		}
    		else
    		{
    			if (is_opera)
    			{
    				caretPos.moveStart('character', (text1+text2).match(/\n/g).length);
    				caretPos.select();
    			}
    			oTextHandle.focus(caretPos);
    		}
    
    txt file icon caretpos fix.txt (681 bytes) 2009-10-31 12:38 +

-Relationships
parent of 0001327closed SMF 2.0 [WYSIWYG] url bbc at end does not exit out of bbc 
parent of 0004516resolvedNorv SMF 2.1 Opera: Javascript errors [Non-Wysiwyg-mode] 
+Relationships

-Notes

bugnote:0006959

regularexpression (Viewer)

So this just affects old opera?

bugnote:0006963

Nao/Gilles (Viewer)

I don't know. I think it affects all browsers that go through the same codepath...?

bugnote:0007892

Nao/Gilles (Viewer)

Could a simple workaround be made for this bug?
Since only tables and lists are concerned AFAIK, a quick fix could be added by moving the cursor by X bytes to the right when [table] is added, and by Y bytes to the right when a list is added...

bugnote:0008085

regularexpression (Viewer)

I've updated the title a little.

I've also been playing about with this.

It seems to be more complicated. I can confirm that surroundText affects this.

The position is also affected by whether there is any content or not, whether any text is selected or not.

bugnote:0009701

Mark Rose (Beta Tester)

Happens in Opera 10, too.

bugnote:0009736

karlbenson (SMF Friend)

Indeed

bugnote:0010653

Nao/Gilles (Viewer)

Okay, here's a fix I cooked up...
I have absolutely no knowledge about textRange and anything, so maybe it just works by magic, I don't know...

At least it works for table and li alike.
Attaching file.

bugnote:0011796

SleePy (Developer)

The proposed fix causes other issues.

bugnote:0011807

Nao/Gilles (Viewer)

Not for me. Which issues?

bugnote:0011835

JBlaze (Viewer)

Happens when quoting posts with quick reply as well

bugnote:0011894

Nao/Gilles (Viewer)

I still don't know what issues my fix cause. ;)

bugnote:0011968

Nao/Gilles (Viewer)

Okay, I've tested with Opera 10.54 and the fix was no longer working because it's using the Mozilla codepath rather than the IE one.
I've devised a new fix and also fixed the Quick Reply bug as reported by JBlaze (thanks).

Feel free to revert if you're not comfortable with the fix, I won't mind. I'm just testing the automatic Mantis bug closing feature. :)

bugnote:0011969

Nao/Gilles (Viewer)

* replaceText() and surroundText() functions didn't work correctly in Opera. Fixed tested with v10.5x (script.js) Revision 9925
+Notes
MantisBT (Modified for SMF Intergration)[^] Copyright © 2000 - 2010 Mantis Group