Results 1 to 2 of 2

Thread: fix proposal for cell.focus is not a function

  1. #1
    Sencha User
    Join Date
    Jul 2016
    Posts
    3
    Vote Rating
    0
      0  

    Default fix proposal for cell.focus is not a function

    adding items to a grid, remove them, then add a new one, i have this issue :

    @ext-all-debug.js?build=1472458188439:205602 Uncaught TypeError: cell.focus is not a function


    fixed by :

    if (cell) { // patch if cell == false => ExtJS error
    cell.focus();
    }


    patch proposal :

    // @2679
    Ext.override(Ext.view.Table, {

    privates: {
    setActionableMode: function(enabled, position) {
    var me = this,
    navModel = me.getNavigationModel(),
    activeEl,
    actionables = me.grid.actionables,
    len = actionables.length,
    i, record, column,
    isActionable = false,
    lockingPartner, cell;
    // No mode change.
    // ownerGrid's call will NOT fire mode change event upon false return.
    if (me.actionableMode === enabled) {
    // If we're not actinoable already, or (we are actionable already at that position) return false.
    // Test using mandatory passed position because we may not have an actionPosition if we are
    // the lockingPartner of an actionable view that contained the action position.
    //
    // If we being told to go into actionable mode but at another position, we must continue.
    // This is just actionable navigation.
    if (!enabled || position.isEqual(me.actionPosition)) {
    return false;
    }
    }
    // If this View or its lockingPartner contains the current focus position, then make the tab bumpers tabbable
    // and move them to surround the focused row.
    if (enabled) {
    if (position && (position.view === me || (position.view === (lockingPartner = me.lockingPartner) && lockingPartner.actionableMode))) {
    isActionable = me.activateCell(position);
    }
    // Did not enter actionable mode.
    // ownerGrid's call will NOT fire mode change event upon false return.
    return isActionable;
    } else {
    // Capture before exiting from actionable mode moves focus
    activeEl = Ext.fly(Ext.Element.getActiveElement());
    // Blur the focused descendant, but do not trigger focusLeave.
    // This is so that when the focus is restored to the cell which contained
    // the active content, it will not be a FocusEnter from the universe.
    if (me.el.contains(activeEl) && !Ext.fly(activeEl).is(me.getCellSelector())) {
    // Row to return focus to.
    record = (me.actionPosition && me.actionPosition.record) || me.getRecord(activeEl);
    column = me.getHeaderByCell(activeEl.findParent(me.getCellSelector()));
    cell = position && position.getCell();
    // Do not allow focus to fly out of the view when the actionables are deactivated
    // (and blurred/hidden). Restore focus to the cell in which actionable mode is active.
    // Note that the original position may no longer be valid, e.g. when the record
    // was removed.
    if (!position || !cell) {
    position = new Ext.grid.CellContext(me).setPosition(record || 0, column || 0);
    cell = position.getCell();
    }
    // Ext.grid.NavigationModel#onFocusMove will NOT react and navigate because the actionableMode
    // flag is still set at this point.

    if (cell) { // @2679 patch if cell == false => ExtJS error
    cell.focus();
    }

    // Let's update the activeEl after focus here
    activeEl = Ext.fly(Ext.Element.getActiveElement());
    // If that focus triggered handlers (eg CellEditor after edit handlers) which
    // programatically moved focus somewhere, and the target cell has been unfocused, defer to that,
    // null out position, so that we do not navigate to that cell below.
    // See EXTJS-20395
    if (!(me.el.contains(activeEl) && activeEl.is(me.getCellSelector()))) {
    position = null;
    }
    }
    // We are exiting actionable mode.
    // Tell all registered Actionables about this fact if they need to know.
    for (i = 0; i < len; i++) {
    if (actionables[i].deactivate) {
    actionables[i].deactivate();
    }
    }
    // If we had begun action (we may be a dormant lockingPartner), make any tabbables untabbable
    if (me.actionRow) {
    me.actionRow.saveTabbableState({
    skipSelf: true,
    includeSaved: false
    });
    }
    if (me.destroyed) {
    return false;
    }
    // These flags MUST be set before focus restoration to the owning cell.
    // so that when Ext.grid.NavigationModel#setPosition attempts to exit actionable mode, we don't recurse.
    me.actionableMode = me.ownerGrid.actionableMode = false;
    me.actionPosition = navModel.actionPosition = me.actionRow = null;
    // Push focus out to where it was requested to go.
    if (position) {
    navModel.setPosition(position);
    }
    }
    }
    }
    });

  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,070
    Answers
    3976
    Vote Rating
    1394
      0  

    Default

    Can you provide a fiddle or more information how to reproduce the issue? I tried with this fiddle and I'm unable to reproduce:



    1. Clicked "Add Items"
    2. Clicked "Remove Items"
    3. Clicked "Add Items"
    4. Observed no errors
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Similar Threads

  1. Replies: 1
    Last Post: 18 May 2016, 11:00 AM
  2. Replies: 1
    Last Post: 27 Oct 2015, 11:57 AM
  3. cell's focus in a grid
    By Fonnit in forum Community Discussion
    Replies: 3
    Last Post: 11 Sep 2012, 9:41 PM
  4. EditorGridPanel losing cell focus and won't delete cell value
    By morbaq in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 27 Aug 2008, 10:25 PM

Tags for this Thread

Posting Permissions

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