From 7dd508946fc048fcb1b408129da89a1251f6d683 Mon Sep 17 00:00:00 2001 From: jlukic Date: Wed, 29 Apr 2015 18:48:51 -0400 Subject: [PATCH] Remove use of :visible, fix backspace on tag when tag is user value --- src/definitions/modules/dropdown.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 5fbbca8b1..e6d706df7 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -674,6 +674,7 @@ $.fn.dropdown = function(parameters) { if(!itemActivated && !pageLostFocus) { if(module.is.multiple()) { module.remove.activeLabel(); + module.hide(); } else if(settings.forceSelection) { module.forceSelection(); @@ -845,6 +846,10 @@ $.fn.dropdown = function(parameters) { caretAtStart = (isFocusedOnSearch && module.get.caretPosition() === 0), $nextLabel ; + if(!hasActiveLabel && !isFocusedOnSearch) { + return; + } + if(pressedKey == keys.leftArrow) { // activate previous label if((isFocused || caretAtStart) && !hasActiveLabel) { @@ -908,6 +913,7 @@ $.fn.dropdown = function(parameters) { } } else if(pressedKey == keys.deleteKey || pressedKey == keys.backspace) { + console.log(caretAtStart, hasActiveLabel); if(hasActiveLabel) { module.verbose('Removing active labels'); if(isLastLabel) { @@ -922,8 +928,7 @@ $.fn.dropdown = function(parameters) { else if(caretAtStart && !hasActiveLabel && pressedKey == keys.backspace) { module.verbose('Removing last label on input backspace'); $activeLabel = $label.last().addClass(className.active); - activeValue = $activeLabel.data('value'); - module.remove.selected(activeValue); + module.remove.labels($activeLabel); event.preventDefault(); } } @@ -1591,7 +1596,7 @@ $.fn.dropdown = function(parameters) { ? forceScroll : false ; - if($item && hasActive) { + if($item && $menu.length > 0 && hasActive) { if(!$menu.hasClass(className.visible)) { $menu.addClass(className.loading); } @@ -2150,8 +2155,8 @@ $.fn.dropdown = function(parameters) { }, visible: function($subMenu) { return ($subMenu) - ? $subMenu.is(':visible') - : $menu.is(':visible') + ? $subMenu.hasClass(className.visible) + : $menu.hasClass(className.visible) ; } },