Results 1 to 5 of 5

Thread: [FIXED-1409]Ext.CycleButton's method setActiveItem suppressEvent parameter is ignored

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    422

    Default [FIXED-1409]Ext.CycleButton's method setActiveItem suppressEvent parameter is ignored

    Ext version tested:
    • Ext 3.3.0


    Adapter used:
    • ext


    css used:
    • only default ext-all.css


    Browser versions tested against:
    • IE8
    • FF3.6
    • Chrome 7


    Operating System:
    • WinXP Pro


    Description:
    • The suppressEvent parameter of Ext.CycleButton's method setActiveItem seems to be ignored. In this testcase a change event handler was added to the cyclebutton. When I do setActiveItem(0, true) with a helper button, the change event is fired.


    Test Case:
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>suppressEvent ignored bug on CycleButton</title>
    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.2.1/resources/css/ext-all.css"/>
    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.2.1/ext-all-debug.js"></script>
    <script type="text/javascript">
    Ext.onReady(function() {
        var cyclebutton=new Ext.CycleButton({
            renderTo: Ext.getBody(),
            showText: true,
            items: [
                {
                    xtype: 'menucheckitem',
                    text: 'English',
                    checked: true,
                    itemId: 'en'
                },
                {
                    xtype: 'menucheckitem',
                    text: 'Franais',
                    itemId: 'fr'
                },
                {
                    xtype: 'menucheckitem',
                    text: 'Nederlands',
                    itemId: 'nl'
                }
            ]
        });
        cyclebutton.on('change', function(btn, item) {
            Ext.Msg.alert('cyclebutton changed', 'Despite the fact that setActiveItem was called with suppressEvent=true');
        });
        var button=new Ext.Button({
            renderTo: Ext.getBody(),
            text: 'reset cyclebutton',
            handler: function() {
                cyclebutton.setActiveItem(0, true);
            }
        });
    });
    </script>
    </head>
    <body></body>
    </html>

    Steps to reproduce the problem:
    • change the cycle button
    • click the second helper button that does setActiveItem(0, true);


    The result that was expected:
    • change event shouldn't fire when I set second parameter of setActiveItem to true


    The result that occurs instead:
    • change event does fire when I set second parameter of setActiveItem to true


    Debugging already done:
    • I guess somehow a internal checkchange event fires setActiveItem without the second parameter, causing the change event to fire.
    Christiaan Westerbeek @ Devotis
    Contact me for help with Ext JS, Node JS, FireBase, AngularJS and Javascript in general. Email me or find me at AirPair to connect.

  2. #2
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    422

    Default

    This override fixed it:
    Code:
    Ext.override(Ext.CycleButton, {
        setActiveItem : function(item, suppressEvent){
            if(!Ext.isObject(item)){
                item = this.menu.getComponent(item);
            }
            if(item){
                if(!this.rendered){
                    this.text = this.getItemText(item);
                    this.iconCls = item.iconCls;
                }else{
                    var t = this.getItemText(item);
                    if(t){
                        this.setText(t);
                    }
                    this.setIconClass(item.iconCls);
                }
                this.activeItem = item;
                if(!item.checked){
                    item.setChecked(true, suppressEvent);
                }
                if(this.forceIcon){
                    this.setIconClass(this.forceIcon);
                }
                if(!suppressEvent){
                    this.fireEvent('change', this, item);
                }
            }
        }
    });
    And while you're at it (meant friendly) add this line as well after the setIconClass line:
    Code:
    this.setIcon(item.icon);
    Christiaan Westerbeek @ Devotis
    Contact me for help with Ext JS, Node JS, FireBase, AngularJS and Javascript in general. Email me or find me at AirPair to connect.

  3. #3
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    422

    Default

    Nor confirmed or fixed in 3.3.1.
    Christiaan Westerbeek @ Devotis
    Contact me for help with Ext JS, Node JS, FireBase, AngularJS and Javascript in general. Email me or find me at AirPair to connect.

  4. #4
    Sencha User
    Join Date
    Jun 2009
    Posts
    751

    Default

    Thanks for the report. This is fixed in SVN.

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    9

    Default

    The bug is still here in ExtJS 4.2.1
    Code:
     setActiveItem: function(item, suppressEvent) {
            var me = this;
    
            if (!Ext.isObject(item)) {
                item = me.menu.getComponent(item);
            }
            if (item) {
                if (!me.rendered) {
                    me.text = me.getButtonText(item);
                    me.iconCls = item.iconCls;
                    me.glyph = item.glyph;
                } else {
                    me.setText(me.getButtonText(item));
                    me.setIconCls(item.iconCls);
                    me.setGlyph(item.glyph);
                }
                me.activeItem = item;
                if (!item.checked) {
                    item.setChecked(true, false); //should be suppressEvent
                }
                if (me.forceIcon) {
                    me.setIconCls(me.forceIcon);
                }
                if (me.forceGlyph) {
                    me.setGlyph(me.forceGlyph);
                }
                if (!suppressEvent) {
                    me.fireEvent('change', me, item);
                }
            }
        },

Similar Threads

  1. Replies: 7
    Last Post: 22 Feb 2010, 6:06 PM
  2. [FIXED-459][3.??] CycleButton setActiveItem bug
    By vladsch in forum Ext 3.x: Bugs
    Replies: 1
    Last Post: 4 Feb 2010, 7:34 AM
  3. [FIXED-261][3.x]CycleButton menu not drawn
    By qooleot in forum Ext 3.x: Bugs
    Replies: 1
    Last Post: 24 Sep 2009, 5:38 PM
  4. [FIXED][3.x] Cyclebutton
    By galdaka in forum Ext 3.x: Bugs
    Replies: 4
    Last Post: 27 May 2009, 6:59 PM
  5. Replies: 1
    Last Post: 18 Feb 2009, 10:37 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
  •