Anonymous Login
04-20-2018 11:44 PM

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002964SMF 2.0public2010-05-24 18:25
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 -
    line 391
    		if (temp_length == 0)
    			caretPos.moveStart('character', -text2.length);
    			caretPos.moveEnd('character', -text2.length);;
    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);;
    			if (is_opera)
    				caretPos.moveStart('character', (text1+text2).match(/\n/g).length);;
    txt file icon caretpos fix.txt (681 bytes) 2009-10-31 12:38 +

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] 



regularexpression (Viewer)

So this just affects old opera?


Nao/Gilles (Viewer)

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


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...


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.


Mark Rose (Beta Tester)

Happens in Opera 10, too.


karlbenson (SMF Friend)



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.


SleePy (Developer)

The proposed fix causes other issues.


Nao/Gilles (Viewer)

Not for me. Which issues?


JBlaze (Viewer)

Happens when quoting posts with quick reply as well


Nao/Gilles (Viewer)

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


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. :)


Nao/Gilles (Viewer)

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