Results 1 to 2 of 2

Thread: [OPEN][3.1] Caret / Cursor Position in Editor Grid Textfield

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Apr 2007
    Posts
    57
    Vote Rating
    2
      0  

    Default [OPEN][3.1] Caret / Cursor Position in Editor Grid Textfield

    Ext version tested:
    • Ext 3.1.0 rev 5770-119


    Adapter used:
    • ext


    css used:
    • only default ext-all.css


    Browser versions tested against:
    • IE8
    • IE6
    • Opera 10


    Operating System:
    • Vista
    • WinXP


    Description:
    • After loading an Editor Grid which contains a Textfield, the cursor / caret is positioned at the beginning of the text field the first time the editor is activated. Subsequent activations position the caret at the end of the text field. This behavior is not observed in Firefox 3.5.6 or Safari 4.0.4


    Test Case:
    See this URL :

    1.) http://www.extjs.com/deploy/dev/exam...edit-grid.html

    2.) http://www.extjs.com/deploy/dev/exam...ow-editor.html


    Steps to reproduce the problem:
    • Using Internet Exlporer or Opera, visit one of the links above and activate a TextField.
      In the Editor Grid example, the Common Name field displays the behavior.
      In the Row Editor example, either of the First Name or Email fields display the behavior.
      After the first activation, the page will need to be refreshed to see the behavior again.


    The result that was expected:
    • The cursor should be positioned at the end of existing text.


    The result that occurs instead:
    • On first activation, the cursor is positioned at the beginning of existing text.


    New fix (3.3):

    Code:
    Ext.override(Ext.Element, {
        focus: function (defer, /* private */dom) {
            var me = this,
                dom = dom || me.dom;
            try {
                if (Number(defer)) {
                    me.focus.defer(defer, null, [null, dom]);
                } else {                
                    dom.focus();
                    dom.value = dom.value;
                    dom.focus();
                    if (dom.sof) {
                        dom.select();
                    }                
                }
            } catch (e) { }       
            return me;
        }
    });
    AND

    Code:
    Ext.override(Ext.form.TextField, {
        preFocus: function () {       
                var el = this.el,
                    isEmpty;
                if (this.emptyText) {
                    if (el.dom.value == this.emptyText) {
                        this.setRawValue('');
                        isEmpty = true;
                    }
                    el.removeClass(this.emptyClass);
                }
                if (this.selectOnFocus || isEmpty) {
                    el.dom.sof = true;
                    el.dom.select();
                }
            }
    });

    Older fix:
    For IE:
    Code:
    Ext.override(Ext.Element, {
        focus: function(defer, /* private */dom) {
            var me = this,
                dom = dom || me.dom;
            try {
                if (Number(defer)) {
                    me.focus.defer(defer, null, [null, dom]);
                } else {
                    dom.focus();
                }
            } catch (e) { }
            //begin override
            if (document.selection) {
                var range = document.selection.createRange();
                if (dom && dom.value) { 
                 range.move('character', dom.value.length);
                 range.select();
                }           
            }
            //end override
            return me;
        }
    });
    })
    Last edited by zachext; 18 Oct 2010 at 4:43 PM. Reason: Added possible fix.

  2. #2
    Sencha User
    Join Date
    Apr 2007
    Posts
    57
    Vote Rating
    2
      0  

    Default

    With the release of 3.3 , the fix noted above triggers a blur on every other field activation if the field editor is a textarea. Does anyone have ideas about what would cause that?

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •