Roundcube Community Forum

Release Support => Pending Issues => Topic started by: jimwillsher on February 25, 2009, 11:05:04 AM

Title: Problem setting focus when replying to messasge (IE7, javascript error)
Post by: jimwillsher on February 25, 2009, 11:05:04 AM
Hi all,

I'm a newbie to Roundcube, having left trusty SquirrelMail behind yesterday.

I'm not sure if I'm missing something, but I'm finding a problem when replying to emails. I have HTML formatting enabled, so it could be a TinyMCE issue, but I'm not sure.

When I reply, the editing window doesn't get focus (cursor) and I'm getting a javascript error:

Line: 3170
Char: 1
Error: Can't move focus to the control becuase it is invisible, not enabled, or of a type that does not accept the focus
Code: 0


I know that javascript errors in IE are often misleading in their line numbers. I only found one .js file which had > 3000 lines in it, but I'm not convinced I'm in the right place.

Can anyone suggest where I might start debugging, or is there a known resolution other than Firefox :D)

IE7, fully patched, Vista x64.

Many thanks,


Jim
Title: Problem setting focus when replying to messasge (IE7, javascript error)
Post by: rosali on February 26, 2009, 01:06:30 AM
Google for CompanionJS (JS debugger for IE).
Title: Problem setting focus when replying to messasge (IE7, javascript error)
Post by: jimwillsher on February 26, 2009, 02:35:16 AM
Many thanks for the link. It's now installed and working, and this seems to be the path to the error:

app.js ( line 168 ) this.init_messageform();
app.js ( line 380 ) this.set_caret2start(_3a);

Line 3169  obj.focus();



As the code is clearly obfuscated it's hard to work out what's going on. So does that give the developers enough info?

My system is fully-patched Vista x64 (using the 32-bit browser). I have no IE addons. The problem only occurs when replying to HTML emails (in HTML format).


Many thanks,



Jim
Title: Problem setting focus when replying to messasge (IE7, javascript error)
Post by: lacri on February 26, 2009, 03:26:46 AM
Hi
rename the app.js to app.js.original and
rename the app.js.src to  app.js

this is the unpacked and developer version from app.js and is human readable.
Title: Problem setting focus when replying to messasge (IE7, javascript error)
Post by: jimwillsher on February 26, 2009, 07:36:52 AM
Many thanks.

Ok, the offending code is this:

this.set_caret2start = function(obj)
    {
    if (obj.createTextRange)
      {
      var range = obj.createTextRange();
      range.collapse(true);
      range.select();
      }
    else if (obj.setSelectionRange)
      obj.setSelectionRange(0,0);

    obj.focus();    };

Unfortunately I'm no javascript - other languages are my area. Can anyone suggest a way forward?

Cheers,


Jim
Title: Problem setting focus when replying to messasge (IE7, javascript error)
Post by: rosali on February 26, 2009, 08:05:14 AM
Try the following:

try{
  obj.focus();
}
catch(e){
}
Title: Problem setting focus when replying to messasge (IE7, javascript error)
Post by: jimwillsher on February 26, 2009, 08:11:46 AM
Hmm....it stops the error, but doesn't give focus to the field, which is a bit of a pain. I need to click the reply field, then jump to the start of the message.

It works correctly when using plain-text emails, so for now I'll just revert back to plain-text and disable the "Compose HTML messages" option.

Many thanks for your help.


Jim
Title: Problem setting focus when replying to messasge (IE7, javascript error)
Post by: rosali on February 26, 2009, 08:30:34 AM
The problem is, that IE does not allow to give focus to an invisible/hidden textarea. I would have to look deeper inside TinyMCE, if there is a way to set the focus into the TinyMCE layer.

TinyMCE:Configuration/auto focus - Moxiecode Documentation Wiki (http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/auto_focus)