thanhlong203 / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

Editor: Script errors in IE when using certain toolbar buttons without focus in the editable field #202

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Using IE (observed with IE6, IE8), visit the goog.editor demo 
https://closure-library.googlecode.com/svn/trunk/closure/goog/demos/editor/edito
r.html
2. Click outside the editable area to make certain that the field does not have 
focus
3. Perform any of the following actions in the editor toolbar:
   * Change the font size
   * Click the bullet/number list buttons
   * Click the increase/decrease indent buttons
   * Click the align left/center/right buttons
   * Click the remove formatting button

What is the expected output? What do you see instead?

I would expect either a no-op, or for the relevant action to be performed in 
either the last place the cursor was, the beginning of the field, or the end of 
the field.

Instead, a script error ('null' is null or not an object) is thrown. This is 
because getRange() is returning null when the editor does not have focus. For 
example, the isCollapsed invocation causes the issue in removeformatting.js:

  var range = this.fieldObject.getRange();
  if (range.isCollapsed()) {
    return;
  }

What version of the product are you using? On what operating system?

Observed locally using r159, though the behavior is present on the current HEAD.

Please provide any additional information below.

This behavior doesn't seem to happen in Gmail. I assume they are not using 
patched files, and are implicitly focusing the field or some other trickery.

I added a similar workaround in my own application via a mousedown handler on 
the toolbar.

I can patch the behavior in Closure, but it's probably worth discussing the 
ideal solution before doing so.

Original issue reported on code.google.com by dereksla...@gmail.com on 16 Aug 2010 at 7:48

GoogleCodeExporter commented 8 years ago

Original comment by pall...@google.com on 15 Jul 2011 at 1:34