From 4c1d7d0456f1187440a81f05fd02ca4cb5127b99 Mon Sep 17 00:00:00 2001 From: jlukic Date: Tue, 21 Jul 2015 18:43:55 -0400 Subject: [PATCH] Fix isssues when using messages instead of labels, with max selection and display count --- RELEASE-NOTES.md | 5 +++- src/definitions/modules/dropdown.js | 40 +++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 38153957e..ca907e4c1 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -2,9 +2,12 @@ ### Version 2.0.6 - July x, 2015 **[Reported Bugs](https://github.com/Semantic-Org/Semantic-UI/issues?q=is%3Aissue+milestone%3A2.0.6+is%3Aclosed)** - - **Dropdown** - Fixed `restore value` sometimes now working correctly due to "animating out" label still being mistaken for selected. - **Dropdown** - Added `set exactly` to remedy confusion of `set selected` not removing current selections with multiple +- **Dropdown** - Fixed issue where dropdowns using `useLabels: false` would not display correct values when displaying current count. + +- **Additional Fixes** +- **Dropdown** - Fixed condition with `useLabels: false` where `maxSelections` would make it impossible to select/remove values ### Version 2.0.5 - July 20, 2015 **[Reported Bugs](https://github.com/Semantic-Org/Semantic-UI/issues?q=is%3Aissue+milestone%3A2.0.5+is%3Aclosed)** diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index dd8d130f2..fd3f7edaa 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -1325,12 +1325,14 @@ $.fn.dropdown = function(parameters) { ? value : text ; - module.set.selected(value, $(this)); - if(module.is.multiple() && !module.is.allFiltered()) { - return; - } - else { - module.hideAndClear(); + if( module.can.activate( $(this) ) ) { + module.set.selected(value, $(this)); + if(module.is.multiple() && !module.is.allFiltered()) { + return; + } + else { + module.hideAndClear(); + } } }, @@ -1369,9 +1371,10 @@ $.fn.dropdown = function(parameters) { }, selectionCount: function() { var - values = module.get.values() + values = module.get.values(), + count ; - return ( module.is.multiple() ) + count = ( module.is.multiple() ) ? $.isArray(values) ? values.length : 0 @@ -1379,6 +1382,7 @@ $.fn.dropdown = function(parameters) { ? 1 : 0 ; + return count; }, transition: function($subMenu) { return (settings.transition == 'auto') @@ -1678,7 +1682,9 @@ $.fn.dropdown = function(parameters) { ; if(selectionCount >= settings.maxSelections) { module.debug('Maximum selection count reached'); - $item.addClass(className.filtered); + if(settings.useLabels) { + $item.addClass(className.filtered); + } module.add.message(message.maxSelections); return true; } @@ -2186,8 +2192,8 @@ $.fn.dropdown = function(parameters) { module.select.nextAvailable($selectedItem); } else { - module.set.text(module.add.variables(message.count)); module.add.value(selectedValue, selectedText, $selected); + module.set.text(module.add.variables(message.count)); $selected.addClass(className.active); } } @@ -2422,7 +2428,7 @@ $.fn.dropdown = function(parameters) { $item.removeClass(className.active); }, filteredItem: function() { - if( module.has.maxSelections() ) { + if(settings.useLabels && module.has.maxSelections() ) { return; } if(settings.useLabels) { @@ -2775,6 +2781,18 @@ $.fn.dropdown = function(parameters) { }, can: { + activate: function($item) { + if(settings.useLabels) { + return true; + } + if(!module.has.maxSelections()) { + return true; + } + if(module.has.maxSelections() && $item.hasClass(className.active)) { + return true; + } + return false; + }, click: function() { return (hasTouch || settings.on == 'click'); },