diff --git a/dist/components/dropdown.js b/dist/components/dropdown.js
index 7057df01b..ee6d3bbe3 100644
--- a/dist/components/dropdown.js
+++ b/dist/components/dropdown.js
@@ -460,6 +460,9 @@ $.fn.dropdown = function(parameters) {
if( module.can.click() ) {
module.bind.intent();
}
+ if(module.has.menuSearch()) {
+ module.focusSearch();
+ }
module.set.visible();
callback.call(element);
});
@@ -827,11 +830,11 @@ $.fn.dropdown = function(parameters) {
},
focusSearch: function(skipHandler) {
- if( module.is.search() && !module.is.focusedOnSearch() ) {
+ if( module.has.search() && !module.is.focusedOnSearch() ) {
if(skipHandler) {
$module.off('focus' + eventNamespace, selector.search);
$search.focus();
- $module.on('focus' + eventNamespace, selector.search, module.event.search.focus)
+ $module.on('focus' + eventNamespace, selector.search, module.event.search.focus);
}
else {
$search.focus();
@@ -1006,6 +1009,9 @@ $.fn.dropdown = function(parameters) {
? module.show
: module.toggle
;
+ if(module.is.bubbledLabelClick(event)) {
+ return;
+ }
if( module.determine.eventOnElement(event, toggleBehavior) ) {
event.preventDefault();
}
@@ -1236,8 +1242,8 @@ $.fn.dropdown = function(parameters) {
hasSubMenu = ($subMenu.length> 0),
hasSelectedItem = ($selectedItem.length > 0),
selectedIsSelectable = ($selectedItem.not(selector.unselectable).length > 0),
- isAdditionWithoutMenu = (settings.allowAdditions && settings.hideAdditions && pressedKey == keys.enter && selectedIsSelectable),
delimiterPressed = (pressedKey == keys.delimiter && settings.allowAdditions && module.is.multiple()),
+ isAdditionWithoutMenu = (settings.allowAdditions && settings.hideAdditions && (pressedKey == keys.enter || delimiterPressed) && selectedIsSelectable),
$nextItem,
isSubMenuItem,
newIndex
@@ -1329,7 +1335,7 @@ $.fn.dropdown = function(parameters) {
.addClass(className.selected)
;
module.set.scrollPosition($nextItem);
- if(settings.selectOnShortcut && module.is.single()) {
+ if(settings.selectOnKeydown && module.is.single()) {
module.set.selectedItem($nextItem);
}
}
@@ -1356,7 +1362,7 @@ $.fn.dropdown = function(parameters) {
.addClass(className.selected)
;
module.set.scrollPosition($nextItem);
- if(settings.selectOnShortcut && module.is.single()) {
+ if(settings.selectOnKeydown && module.is.single()) {
module.set.activeItem($nextItem);
module.set.selected(module.get.choiceValue($nextItem), $nextItem);
}
@@ -2068,7 +2074,7 @@ $.fn.dropdown = function(parameters) {
$nextSelectedItem
.addClass(className.selected)
;
- if(settings.selectOnShortcut && module.is.single()) {
+ if(settings.selectOnKeydown && module.is.single()) {
module.set.selectedItem($nextSelectedItem);
}
$menu
@@ -2257,7 +2263,7 @@ $.fn.dropdown = function(parameters) {
module.set.scrollPosition($nextValue);
$selectedItem.removeClass(className.selected);
$nextValue.addClass(className.selected);
- if(settings.selectOnShortcut && module.is.single()) {
+ if(settings.selectOnKeydown && module.is.single()) {
module.set.selectedItem($nextValue);
}
}
@@ -2291,7 +2297,7 @@ $.fn.dropdown = function(parameters) {
newValue
;
if(hasInput) {
- if(settings.allowReselection && stringValue == currentValue) {
+ if(!settings.allowReselection && stringValue == currentValue) {
module.verbose('Skipping value update already same value', value, currentValue);
if(!module.is.initialLoad()) {
return;
@@ -2833,6 +2839,9 @@ $.fn.dropdown = function(parameters) {
},
has: {
+ menuSearch: function() {
+ return (module.has.search() && $search.closest($menu).length > 0);
+ },
search: function() {
return ($search.length > 0);
},
@@ -2914,6 +2923,9 @@ $.fn.dropdown = function(parameters) {
active: function() {
return $module.hasClass(className.active);
},
+ bubbledLabelClick: function(event) {
+ return $(event.target).is('select, input') && $module.closest('label').length > 0;
+ },
alreadySetup: function() {
return ($module.is('select') && $module.parent(selector.dropdown).length > 0 && $module.prev().length === 0);
},
@@ -3411,7 +3423,7 @@ $.fn.dropdown.settings = {
apiSettings : false,
- selectOnShortcut : true, // Whether selection should occur automatically when keyboard shortcuts used
+ selectOnKeydown : true, // Whether selection should occur automatically when keyboard shortcuts used
minCharacters : 0, // Minimum characters required to trigger API call
saveRemoteData : true, // Whether remote name/value pairs should be stored in sessionStorage to allow remote data to be restored on page refresh
throttle : 200, // How long to wait after last user input to search remotely
@@ -3546,7 +3558,7 @@ $.fn.dropdown.settings = {
menu : '.menu',
message : '.message',
menuIcon : '.dropdown.icon',
- search : 'input.search, .menu > .search > input',
+ search : 'input.search, .menu > .search > input, .menu input.search',
sizer : '> input.sizer',
text : '> .text:not(.icon)',
unselectable : '.disabled, .filtered'
@@ -3613,7 +3625,10 @@ $.fn.dropdown.settings.templates = {
html = ''
;
$.each(values, function(index, option) {
- html += '
' + option[fields.name] + '
';
+ html += (option.disabled)
+ ? '' + option[fields.name] + '
'
+ : '' + option[fields.name] + '
'
+ ;
});
return html;
},
diff --git a/dist/components/dropdown.min.js b/dist/components/dropdown.min.js
index 0ea4b3705..c3a3a659e 100644
--- a/dist/components/dropdown.min.js
+++ b/dist/components/dropdown.min.js
@@ -8,5 +8,5 @@
* http://opensource.org/licenses/MIT
*
*/
-!function(e,t,n,i){"use strict";t="undefined"!=typeof t&&t.Math==Math?t:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.dropdown=function(a){var o,s=e(this),r=e(n),l=s.selector||"",c="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],v=arguments[0],m="string"==typeof v,f=[].slice.call(arguments,1);return s.each(function(h){var g,p,b,w,x,S,C,y,A=e.isPlainObject(a)?e.extend(!0,{},e.fn.dropdown.settings,a):e.extend({},e.fn.dropdown.settings),T=A.className,k=A.message,L=A.fields,I=A.keys,D=A.metadata,q=A.namespace,R=A.regExp,V=A.selector,O=A.error,E=A.templates,M="."+q,F="module-"+q,z=e(this),P=e(A.context),H=z.find(V.text),j=z.find(V.search),U=z.find(V.sizer),N=z.find(V.input),W=z.find(V.icon),B=z.prev().find(V.text).length>0?z.prev().find(V.text):z.prev(),K=z.children(V.menu),$=K.find(V.item),Q=!1,Y=!1,G=!1,J=this,X=z.data(F);y={initialize:function(){y.debug("Initializing dropdown",A),y.is.alreadySetup()?y.setup.reference():(y.setup.layout(),y.refreshData(),y.save.defaults(),y.restore.selected(),y.create.id(),y.bind.events(),y.observeChanges(),y.instantiate())},instantiate:function(){y.verbose("Storing instance of dropdown",y),X=y,z.data(F,y)},destroy:function(){y.verbose("Destroying previous dropdown",z),y.remove.tabbable(),z.off(M).removeData(F),K.off(M),r.off(w),S&&S.disconnect(),C&&C.disconnect()},observeChanges:function(){"MutationObserver"in t&&(S=new MutationObserver(function(e){y.debug("