Advertisement:

View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0002964SMF 2.0public2009-01-21 02:562010-05-24 18:25
ReporterNao/Gilles 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
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 Filestxt file icon caretpos fix.txt [^] (681 bytes) 2009-10-31 12:38 [Show Content]

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

-  Notes
(0006959)
regularexpression (Viewer)
2009-01-21 18:23

So this just affects old opera?
(0006963)
Nao/Gilles (Viewer)
2009-01-22 02:02

I don't know. I think it affects all browsers that go through the same codepath...?
(0007892)
Nao/Gilles (Viewer)
2009-04-07 17:40

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...
(0008085)
regularexpression (Viewer)
2009-04-25 16:52

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.
(0009701)
Mark Rose (Beta Tester)
2009-09-12 21:20

Happens in Opera 10, too.
(0009736)
karlbenson (SMF Friend)
2009-09-13 12:11

Indeed
(0010653)
Nao/Gilles (Viewer)
2009-10-31 12:38

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.
(0011796)
SleePy (Developer)
2010-04-15 17:11

The proposed fix causes other issues.
(0011807)
Nao/Gilles (Viewer)
2010-04-16 11:10

Not for me. Which issues?
(0011835)
JBlaze (Viewer)
2010-04-28 03:20

Happens when quoting posts with quick reply as well
(0011894)
Nao/Gilles (Viewer)
2010-05-08 11:49

I still don't know what issues my fix cause. ;)
(0011968)
Nao/Gilles (Viewer)
2010-05-24 18:25

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. :)
(0011969)
Nao/Gilles (Viewer)
2010-05-24 18:25

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