Browse Source

Fix isssues when using messages instead of labels, with max selection and display count

pull/2710/head
jlukic 9 years ago
parent
commit
4c1d7d0456
2 changed files with 33 additions and 12 deletions
  1. 5
      RELEASE-NOTES.md
  2. 40
      src/definitions/modules/dropdown.js

5
RELEASE-NOTES.md

@ -2,9 +2,12 @@
### Version 2.0.6 - July x, 2015 ### 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)** **[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** - 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** - 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 ### 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)** **[Reported Bugs](https://github.com/Semantic-Org/Semantic-UI/issues?q=is%3Aissue+milestone%3A2.0.5+is%3Aclosed)**

40
src/definitions/modules/dropdown.js

@ -1325,12 +1325,14 @@ $.fn.dropdown = function(parameters) {
? value ? value
: text : 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() { selectionCount: function() {
var var
values = module.get.values()
values = module.get.values(),
count
; ;
return ( module.is.multiple() )
count = ( module.is.multiple() )
? $.isArray(values) ? $.isArray(values)
? values.length ? values.length
: 0 : 0
@ -1379,6 +1382,7 @@ $.fn.dropdown = function(parameters) {
? 1 ? 1
: 0 : 0
; ;
return count;
}, },
transition: function($subMenu) { transition: function($subMenu) {
return (settings.transition == 'auto') return (settings.transition == 'auto')
@ -1678,7 +1682,9 @@ $.fn.dropdown = function(parameters) {
; ;
if(selectionCount >= settings.maxSelections) { if(selectionCount >= settings.maxSelections) {
module.debug('Maximum selection count reached'); module.debug('Maximum selection count reached');
$item.addClass(className.filtered);
if(settings.useLabels) {
$item.addClass(className.filtered);
}
module.add.message(message.maxSelections); module.add.message(message.maxSelections);
return true; return true;
} }
@ -2186,8 +2192,8 @@ $.fn.dropdown = function(parameters) {
module.select.nextAvailable($selectedItem); module.select.nextAvailable($selectedItem);
} }
else { else {
module.set.text(module.add.variables(message.count));
module.add.value(selectedValue, selectedText, $selected); module.add.value(selectedValue, selectedText, $selected);
module.set.text(module.add.variables(message.count));
$selected.addClass(className.active); $selected.addClass(className.active);
} }
} }
@ -2422,7 +2428,7 @@ $.fn.dropdown = function(parameters) {
$item.removeClass(className.active); $item.removeClass(className.active);
}, },
filteredItem: function() { filteredItem: function() {
if( module.has.maxSelections() ) {
if(settings.useLabels && module.has.maxSelections() ) {
return; return;
} }
if(settings.useLabels) { if(settings.useLabels) {
@ -2775,6 +2781,18 @@ $.fn.dropdown = function(parameters) {
}, },
can: { 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() { click: function() {
return (hasTouch || settings.on == 'click'); return (hasTouch || settings.on == 'click');
}, },

Loading…
Cancel
Save