Results 1 to 6 of 6

Thread: [FIXED][3.0rc3] Menu beforeshow event not firing

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User
    Join Date
    Feb 2009
    Posts
    97
    Vote Rating
    0
      0  

    Default [TENT] [3.0rc3] Menu beforeshow event not firing

    Ext version tested:
    • Ext 3.0 RC3
    Browser versions tested against:
    • IE7
      FF3
    Operating System:
    • WinXP Pro
    Description:
    • 'beforeshow' event not firing.
    Test Case:
    Code:
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <link rel="stylesheet" type="text/css" href="../../../ext-3.0-rc3/resources/css/ext-all.css">
      <script type="text/javascript" src="../../../ext-3.0-rc3/adapter/ext/ext-base.js"></script>
      <script type="text/javascript" src="../../../ext-3.0-rc3/ext-all-debug.js"></script>
      <title id="page-title">Title</title>
      <script type="text/javascript">
      Ext.BLANK_IMAGE_URL = '../../../ext-3.0-rc2/resources/images/default/s.gif';
    Ext.onReady(function() {
        Ext.QuickTips.init();
        var menu = new Ext.menu.Menu({
            items: [
                {
                    text: 'An item'
                }
            ]
        });
        menu.on('beforeshow', function(menu) {
            alert('beforeshow event');
        });
        var root = new Ext.tree.TreeNode({
            text: 'A Node'
        });
        var treePanel = new Ext.tree.TreePanel({
            contextMenu: menu,
            root: root
        });
        treePanel.on('contextmenu', function(node, evt) {
            menu.showAt(evt.getXY());
            evt.stopEvent();
        });
        var mainPortal = new Ext.Viewport({
            title: 'Main Portal',
            layout: 'fit',
            items: [treePanel]
        });
    });
      </script>
    </head>
    <body>
    </body>
    </html>
    See this URL : http://

    Steps to reproduce the problem:
    • Right click on the tree node 'A Node'.
    The result that was expected:
    • An alert box with the message 'beforeshow event'.
    The result that occurs instead:
    • The menu is shown.
    Screenshot or Video:

    Debugging already done:
    • none
    Possible fix:

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    132
      0  

    Default

    Suggested fix: Move beforeshow call from show() to showAt().
    Code:
    Ext.override(Ext.menu.Menu, {
        show : function(el, pos, parentMenu){
            if(this.floating){
                this.parentMenu = parentMenu;
                if(!this.el){
                    this.render();
                    this.doLayout(false, true);
                }
                //if(this.fireEvent('beforeshow', this) !== false){
                    this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign, this.defaultOffsets), parentMenu, false);
                //}
            }else{
                Ext.menu.Menu.superclass.show.call(this);
            }
        },
        showAt : function(xy, parentMenu,  _e){
            if(this.fireEvent('beforeshow', this) !== false){
                this.parentMenu = parentMenu;
                if(!this.el){
                    this.render();
                }
                this.el.setXY(xy);
                if(this.enableScrolling){
                    this.constrainScroll(xy[1]);
                }
                this.el.show();
                Ext.menu.Menu.superclass.onShow.call(this);
                if(Ext.isIE){
                    this.layout.doAutoSize();
                    if(!Ext.isIE8){
                        this.el.repaint();
                    }
                }
                this.hidden = false;
                this.focus();
                this.fireEvent("show", this);
            }
        }
    });

  3. #3
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,212
    Vote Rating
    1006
      0  

    Default

    Possible. The behaviour of components is that show will fire the beforeshow event. In this case, you're calling showAt directly, which isn't show().
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  4. #4
    Ext User
    Join Date
    Feb 2009
    Posts
    97
    Vote Rating
    0
      0  

    Default

    Hi~~

    I just downloaded the realease version of ExtJS 3.0.0 and I am still getting the same behaviour. So should I manually override the methods or will this be fixed in some future patch?

    Many thanks

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,212
    Vote Rating
    1006
      0  

    Default

    I think what Condor suggested makes sense. Show will either call the superclass show method or showAt, so moving beforeshow over would be consistent.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #6
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,212
    Vote Rating
    1006
      0  

    Default

    This has been committed to the trunk.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

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