diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index dbff38cea..4528e2485 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -13,6 +13,7 @@ **Critical Bugs** - **API** - Fixed bug causing `cache: 'local'` not to return the localstorage cached results in some cases - **API** - Fixes bug where `beforeSend` would not correctly cancel request when `return false;` is used in callback. #3660 +- **Dropdown** - Fixed bug where `search selection` would not let you move back in an entered search string with left arrow #3596 -**Form Validation / Dropdown** - Fixed issue where using "enter" key in a `search dropdown` could cause a form to be submitted #3676 -**Divider** - Fixed issue where descenders like "g" would be cut off in `horizontal divider` #3585 diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 99a2e2394..087e5cc1a 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -1191,38 +1191,41 @@ $.fn.dropdown = function(parameters) { event.preventDefault(); } - // left arrow (hide sub-menu) - if(pressedKey == keys.leftArrow) { + // sub-menu actions + if(hasSelectedItem) { - isSubMenuItem = ($parentMenu[0] !== $menu[0]); + if(pressedKey == keys.leftArrow) { - if(isSubMenuItem) { - module.verbose('Left key pressed, closing sub-menu'); - module.animate.hide(false, $parentMenu); - $selectedItem - .removeClass(className.selected) - ; - $parentMenu - .closest(selector.item) - .addClass(className.selected) - ; - event.preventDefault(); + isSubMenuItem = ($parentMenu[0] !== $menu[0]); + + if(isSubMenuItem) { + module.verbose('Left key pressed, closing sub-menu'); + module.animate.hide(false, $parentMenu); + $selectedItem + .removeClass(className.selected) + ; + $parentMenu + .closest(selector.item) + .addClass(className.selected) + ; + event.preventDefault(); + } } - } - // right arrow (show sub-menu) - if(pressedKey == keys.rightArrow) { - if(hasSubMenu) { - module.verbose('Right key pressed, opening sub-menu'); - module.animate.show(false, $subMenu); - $selectedItem - .removeClass(className.selected) - ; - $subMenu - .find(selector.item).eq(0) - .addClass(className.selected) - ; - event.preventDefault(); + // right arrow (show sub-menu) + if(pressedKey == keys.rightArrow) { + if(hasSubMenu) { + module.verbose('Right key pressed, opening sub-menu'); + module.animate.show(false, $subMenu); + $selectedItem + .removeClass(className.selected) + ; + $subMenu + .find(selector.item).eq(0) + .addClass(className.selected) + ; + event.preventDefault(); + } } }