Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-6547 in a recent build.
  1. #1
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    112
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default [4.1.0] Window is not closed on Esc

    [4.1.0] Window is not closed on Esc


    Hi,

    Apologize if it has been reported before, I was unable to find.

    Also I assume it is a known bug. But I decided to report.

    REQUIRED INFORMATION


    Ext version tested:
    • Ext 4.1.0
    Browser versions tested against:
    • Any
    DOCTYPE tested against:
    • Any
    Description:
    • A Window is not closed on Esc according to
    http://docs.sencha.com/ext-js/4-1/#!/api/Ext.window.Window-cfg-onEsc

    Steps to reproduce the problem:
    • Focus any Window and press Esc.
    The result that was expected:
    • The window is closed.
    The result that occurs instead:
    • The Window is not closed.
    Test Case:

    Please see the steps to reproduce.

    HELPFUL INFORMATION


    Debugging already done:
    • The problem lies within the Window afterRender function. Its keyMap is always disabled.
    Window afterRender
    Code:
    afterRender: function() {
        var me = this,
            keyMap;
    
        me.callParent();
    
        // Initialize
        if (me.maximized) {
            me.maximized = false;
            me.maximize();
        }
    
        if (me.closable) {
            keyMap = me.getKeyMap();
            keyMap.on(27, me.onEsc, me);
    
            //if (hidden) { ? would be consistent w/before/afterShow...
                keyMap.disable();
            //}
        }
    }
    Possible fix:
    • Workaround. I just enable the keyMap for now.
      Code:
      win.getKeyMap().enable();

  2. #2
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    112
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Dear ExtJS team,

    Could someone have a chance to look at the problem?

  3. #3
    Sencha - Ext JS Dev Team Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    322
    Vote Rating
    87
    Phil Guerrant is just really nice Phil Guerrant is just really nice Phil Guerrant is just really nice Phil Guerrant is just really nice Phil Guerrant is just really nice

      0  

    Default


    Can you provide a test case please? The following works fine for me:

    Code:
    Ext.onReady(function() {
        Ext.widget({
            xtype: 'window',
            height: 100,
            width: 100,
            title: 'hi'
        }).show();
    });
    When I press the escape key the window closes as expected.
    Phil Guerrant
    Ext JS - Development Team

  4. #4
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    112
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Weird, it is really not reproducible with your test case.

    But I am able to reproduce with this one.
    Code:
    Ext.onReady(function () {
        Ext.create("Ext.window.Window", {
            height   : 100,
            width    : 200,
            hidden   : false,
            html     : "Press Esc",
            renderTo : Ext.getBody()                
        });
    });
    It is reproducible with 4.1.1 rc2 as well.

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    It's enabled on show.

    Must never explicitly go through show if you use renderTo.

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Uncomment that test. And make it "if (me.hidden) {"

    It only needs to disable it if it's hidden.

  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The act of rendering does not focus a Component.

    It's the show process, and resulting toFront process which does that for a Window.

    The solution is to use the code that Phil posted. Call show, and the Window will autoRender and focus.

  8. #8
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    112
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Hi,

    Ok, it's not auto-focused. But a user can focus that Window manually and expect it will be closed on Esc. No?

  9. #9
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Yes, if you focus it, then it's KeyMap will receive key events, and listen for ESC.

    You should not use renderTo for Windows. They autoRender just in time when you first show them.

  10. #10
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    112
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Thanks for the advice.

    But will it be rendered in Ext.getBody() all the time?

    What about if a developer would like to render the Window into a <form> which is within the <body>? To cause the Window input elements to be automatically submitted.

Thread Participants: 2