Chandusangale / dropdown-check-list

Automatically exported from code.google.com/p/dropdown-check-list
1 stars 0 forks source link

Setting focus with keyboard commands #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Press Esc while dropdown is open and focus is inside of dropdown.
2. OR press ALT+down while dropdown is open (slightly different problem
with much the same result).

What is the expected output? What do you see instead?
Expect focus to be returned to control wrapper.  Instead, focus is still on
items inside the dropdown, despite those items being offscreen.

What version of the product are you using? On what operating system?
0.9 in Firefox 3.62 and IE 8.

Please provide any additional information below.
The following is the relevant code section that I used to correct the issue
(or see attached).  Since I also modified the keyboard handlers because I
found the defaults insufficient -- you can't navigate the control when it's
closed like you can a regular dropdown -- I'm also including that code.

        _isDropDownOpenKey: function(e) {
            return (
                $.ui.keyCode.SPACE == (e.keyCode || e.which) ||
                $.ui.keyCode.DOWN == (e.keyCode || e.which) ||
                $.ui.keyCode.UP == (e.keyCode || e.which)
            );
        },
        _isDropDownKeyShortcut: function(e) {
            return e.altKey && ($.ui.keyCode.DOWN == (e.keyCode ||
e.which)); // Alt + Down Arrow
        },
        _isDropDownCloseKey: function(e) {
            return (
                $.ui.keyCode.ESCAPE == (e.keyCode || e.which) ||
                (e.altKey && ($.ui.keyCode.UP == (e.keyCode || e.which)))
            );
        },
        _handleKeyboard: function(e) {
            var self = this;
            if (self._isDropDownKeyShortcut(e)) {
                e.stopPropagation();
                self._toggleDropContainer();
                if(self.dropWrapper.drop)
                    self.dropWrapper.find("input:first").focus();
                else
                    self.controlWrapper.find("span:first").focus();
            } else if (!self.dropWrapper.drop && self._isDropDownOpenKey(e)) {
                e.stopPropagation();
                self._toggleDropContainer();
                self.dropWrapper.find("input:first").focus();
            } else if (self.dropWrapper.drop && self._isDropDownCloseKey(e)) {
                self._toggleDropContainer();
                self.controlWrapper.find("span:first").focus();
            }
        },

Original issue reported on code.google.com by welma...@gmail.com on 24 Mar 2010 at 2:38

Attachments:

GoogleCodeExporter commented 9 years ago
Version 1.0 has reworked the key handling quite a bit, so you may want to try 
it again. I will take a closer look at your code when working 1.1

Original comment by womohun...@ittrium.com on 14 Sep 2010 at 2:39

GoogleCodeExporter commented 9 years ago
Version 1.1 address many of the keyboard processing issues, trying to keep the 
taborder and focus straight.
Normal <select multiple> items are inherently 'open' so we have a limited 
example of what the user expects there. But single <select> options open on the 
keyboard shortcut of alt-down. DDCL will stick with this convention and will 
NOT open on space, up, or down.

Original comment by womohun...@ittrium.com on 16 Sep 2010 at 6:47

GoogleCodeExporter commented 9 years ago
Thanks for getting to this.

Original comment by welma...@gmail.com on 16 Sep 2010 at 6:57

GoogleCodeExporter commented 9 years ago
Issue addressed with version 1.1.  Please let me know if you have any problems.

Original comment by womohun...@ittrium.com on 23 Sep 2010 at 3:35