Hi All!
I'm using ExtJS 2.1, FF 3.5
The problem is with
PHP Code:
this.bodyTextArea = new Ext.form.HtmlEditor({
id: 'bodyTextAreaSendEmailPopup',
fieldLabel: 'Body',
labelSeparator: '',
defaultAutoCreate : {
tag: "textarea",
style:"width:500px;height:" + (config.showSentData ? "135px;": "150px;"),
autocomplete: "off"
},
value: data.body || ((config.isAttachments ? '' : 'Hi ${name},<br>') + sfa.user.signature.toString().replace(/\r/g,"")),
enableSourceEdit: false,
enableColors: false
});
As you can see the HtmlEditor is created filled with some default value. The error is when I'm clicking on textrea after 'Hi ${name},' (to enter my actual message text) the cursor is moved to the very begining of textarea, i.e. before word 'Hi'. This also happens when clicking at the end of each line but not happens when clicking inside some word. I checked this behaviour in Chrome, and all just works fine.
I have found the reason - it's the code (method of HtmlEditor)
PHP Code:
onFirstFocus : function(){
this.activated = true;
this.tb.items.each(function(item){
item.enable();
});
if(Ext.isGecko){ // <<<<--VVV-- THIS CAUSES BUG
this.win.focus();
var s = this.win.getSelection();
if(!s.focusNode || s.focusNode.nodeType != 3){
var r = s.getRangeAt(0);
r.selectNodeContents(this.getEditorBody());
r.collapse(true);
this.deferFocus();
}
try{
this.execCmd('useCSS', true);
this.execCmd('styleWithCSS', false);
}catch(e){}
} // <<<<-- TILL HERE
this.fireEvent('activate', this);
}
I guess this behaviour happens when performing initial click on position before '<br>'. So when I change my code to
PHP Code:
this.bodyTextArea = new Ext.form.HtmlEditor({
id: 'bodyTextAreaSendEmailPopup',
fieldLabel: 'Body',
labelSeparator: '',
defaultAutoCreate : {
tag: "textarea",
style:"width:500px;height:" + (config.showSentData ? "135px;": "150px;"),
autocomplete: "off"
},
onFirstFocus : function() { // <<-- NOTE THIS
this.activated = true;
this.tb.items.each(function(item) {
item.enable();
});
this.fireEvent('activate', this);
},
value: data.body || ((config.isAttachments ? '' : 'Hi ${name},<br>') + sfa.user.signature.toString().replace(/\r/g,"")),
enableSourceEdit: false,
enableColors: false
});
it seems to do the trick. Anyways, my question is couldn't I introduce some new error by this change (as I think those code I noticed above was about solving some gecko-specific issue)?
Thanks.