Results 1 to 7 of 7

Thread: Menu button does not regain focus when its menu is closed when inside of a window

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Ext JS Premium Member simeon's Avatar
    Join Date
    Mar 2007
    Location
    Austin, Texas
    Posts
    227

    Default Menu button does not regain focus when its menu is closed when inside of a window

    See Example:
    https://fiddle.sencha.com/#fiddle/433

    Steps to repro:
    click menu button and then hit escape key
    click down arrow.

    Note that the menu opens again proving the button has regained focus when the menu was closed

    now click the other button to open the dialog example

    tab to the button
    Hit enter key to deploy menu
    hit escape key
    hit tab key
    Notice that the first field is now focused.

    When a menu closes inside of a window it passes focus to the window instead of the button that opened the menu.

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report. I'm not sure this is a bug. The escape key closes the entire window as it does in the example:
    http://docs.sencha.com/extjs/4.2.1/#....window.Window

  3. #3
    Ext JS Premium Member simeon's Avatar
    Join Date
    Mar 2007
    Location
    Austin, Texas
    Posts
    227

    Default

    The escape key closes the menu flyout. then it should pass focus to the menu button.
    If the window has focus it will close when you hit the escape key.

    This is definitely a bug.

  4. #4
    Ext JS Premium Member simeon's Avatar
    Join Date
    Mar 2007
    Location
    Austin, Texas
    Posts
    227

    Default

    bump.
    After stepping through the code it looks like the button gets focus but some sort of click is being simulated that causes the window to get focus.

    There are delays that are making it hard for me to track down whats happening.

    Deferring the focus doesn't seem to have any effect.

  5. #5
    Ext JS Premium Member simeon's Avatar
    Join Date
    Mar 2007
    Location
    Austin, Texas
    Posts
    227

    Default

    The problem expresses itself in the ZIndexManager

    the register Method calls onComponentHide which calls _activateLast()

    Which iterates the zIndexStack looking for the next floating component to select

    It finds our window class and calls _setActiveChild which makes the window have focus

    Code:
    // Hook into Component's afterHide processing
            comp.afterHide = function() {
                compAfterHide.apply(comp, arguments);
                me.onComponentHide(comp);
            };

    compAfterHide.apply(comp, arguments);
    kicks off the button menu specific code for setting focus after the menu close


    me.onComponentHide(comp);
    this kicks off the zIndexManager specific code for setting focus after the menu hides.

    the ZindexManager code happens after the menu code;



    I think if you reorder the two calls in the afterHide it will fix this issue

    This seems to work but I am not sure what impact it will have elsewhere:
    Code:
    Ext.define('Taco.overrides.ZIndexManager', {
        override: 'Ext.ZIndexManager',
        register: function (comp) {
            var me = this;
    
            
            var me = this,
                compAfterHide = comp.afterHide;
    
            if (comp.zIndexManager) {
                comp.zIndexManager.unregister(comp);
            }
            comp.zIndexManager = me;
    
            me.map[comp.id] = comp;
            me.zIndexStack.push(comp);
    
            // Hook into Component's afterHide processing
            comp.afterHide = function () {
                
                // reverse the order of these callse
                // call me first. I will do the default focus selection 
                me.onComponentHide(comp);
                // call me second. I will do any subclass specific focus selection.
                compAfterHide.apply(comp, arguments);
            };
        }
        
    });

  6. #6
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the follow-up. I have opened a bug in our bug tracker.

  7. #7
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Have you tried your code against a recent nightly? Not sure if this helps you, but I'm not seeing the issue anymore using the 3/10 release.

Posting Permissions

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