Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1799 in a recent build.
  1. #1
    Sencha User
    Join Date
    Sep 2010
    Location
    Belgium
    Posts
    29
    Vote Rating
    0
    strictlyphp is on a distinguished road

      0  

    Default Ext.picker.Picker updateSlots (setSlots) doesn't remove all previously set items

    Ext.picker.Picker updateSlots (setSlots) doesn't remove all previously set items


    REQUIRED INFORMATION

    Ext version tested:
    • Sencha Touch 2 Beta 1
    Browser versions tested against:
    • Chromium 16.0.912.77 (Developer Build 118311 Linux)
    DOCTYPE tested against:
    • html
    Description:
    • Ext.picker.Picker - updateSlots does not remove all items before adding new ones.
    Steps to reproduce the problem:
    • Create an Ext.picker.Picker with more than one slot (e.g. Ext.picker.Date) and cause setSlots to be called after creation of the component.
    • e.g. try calling Ext.picker.Date.setYearFrom() (this triggers createSlots() -> setSlots()).
    • With 3 slots it results in the last one not being removed after the second call to setSlots() and thus having 4 slots after that.
    The result that was expected:
    • 3 slots in Ext.picker.Date.getItems() (besides the Toolbar)
    The result that occurs instead:
    • 4 slots in Ext.picker.Date.getItems() (besides the Toolbar)
    Test Case:

    Code:
    var picker = Ext.create('Ext.picker.Date');
    console.log(picker.getInnerItems().length); // 3
    picker.setYearFrom(2005);
    console.log(picker.getInnerItems().length); // 4, should still be 3


    HELPFUL INFORMATION


    Debugging already done:
    • updateSlots() in Ext.picker.Picker causes this
    Possible fix:
    • The line this.remove(innerItems[i]); in updateSlots() should be this.remove(innerItems[0]); since removing items from the Array causes the indexes to change.
    Operating System:
    • Ubuntu 11.10

  2. #2
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    21
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    Damn, good catch!

    I've updated the code to use removeAll() for the next release - as removeAll() removes all innerItems now.

    Heres a quick override for the time being:

    Code:
    Ext.define('Ext.overrides.picker.UpdateSlots', {
        overrides: 'Ext.picker.Picker',
    
        updateSlots: function(newSlots) {
            this.removeAll();
    
            if (newSlots) {
                this.add(newSlots);
            }
    
            this.updateUseTitles(this.getUseTitles());
        }
    });
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  4. #4
    Sencha User
    Join Date
    Sep 2010
    Location
    Belgium
    Posts
    29
    Vote Rating
    0
    strictlyphp is on a distinguished road

      0  

    Default


    Perfect, thx!

Thread Participants: 2

Tags for this Thread