From 4fc448ed4751258fc04564a3cbab2e909c19f196 Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 26 Mar 2015 18:04:35 -0400 Subject: [PATCH] Fixes placeholder value in select multiple --- src/definitions/modules/dropdown.js | 42 +++++++++++++++------------ src/definitions/modules/dropdown.less | 10 ++++--- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index a11b725e5..bbd8ffd25 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -580,7 +580,7 @@ $.fn.dropdown = function(parameters) { } }, input: function(event) { - if(module.is.searchSelection()) { + if(module.is.multiple() || module.is.searchSelection()) { module.set.filtered(); } clearTimeout(module.timer); @@ -1090,7 +1090,7 @@ $.fn.dropdown = function(parameters) { ? preserveHTML : settings.preserveHTML ; - if($choice !== undefined) { + if($choice) { if($choice.find(selector.menu).length > 0) { module.verbose('Retreiving text of element with sub-menu'); $choice = $choice.clone(); @@ -1107,6 +1107,9 @@ $.fn.dropdown = function(parameters) { }, choiceValue: function($choice, choiceText) { choiceText = choiceText || module.get.choiceText($choice); + if(!$choice) { + return false; + } return ($choice.data(metadata.value) !== undefined) ? $choice.data(metadata.value) : (typeof choiceText === 'string') @@ -1278,14 +1281,10 @@ $.fn.dropdown = function(parameters) { }, clear: function() { - var - placeholderText = $module.data(metadata.placeholderText) - ; - module.set.text(placeholderText); + module.set.placeholderText(); module.clearValue(); module.remove.activeItem(); module.remove.selectedItem(); - $text.addClass(className.placeholder); }, clearValue: function() { @@ -1306,10 +1305,16 @@ $.fn.dropdown = function(parameters) { $search.css('width', searchWidth); } } - else { + else if( !module.is.multiple() || module.is.multiple() && $input.val() == '') { $text.removeClass(className.filtered); } }, + placeholderText: function(text) { + module.debug('Restoring placeholder text'); + text = text || $module.data(metadata.placeholderText); + module.set.text(placeholderText); + $text.addClass(className.placeholder); + }, tabbable: function() { if( module.has.search() ) { module.debug('Searchable dropdown initialized'); @@ -1375,16 +1380,7 @@ $.fn.dropdown = function(parameters) { } }, text: function(text) { - if(settings.action == 'combo') { - module.debug('Changing combo button text', text, $combo); - if(settings.preserveHTML) { - $combo.html(text); - } - else { - $combo.text(text); - } - } - else if(settings.action !== 'select') { + if(settings.action !== 'select') { module.debug('Changing text', text, $text); $text .removeClass(className.filtered) @@ -1397,6 +1393,15 @@ $.fn.dropdown = function(parameters) { $text.text(text); } } + else if(settings.action == 'combo') { + module.debug('Changing combo button text', text, $combo); + if(settings.preserveHTML) { + $combo.html(text); + } + else { + $combo.text(text); + } + } }, value: function(value, text, $selected) { var @@ -1557,6 +1562,7 @@ $.fn.dropdown = function(parameters) { } if(module.is.multiple()) { module.remove.label(selectedValue); + module.set.filtered(); } $selectedItem .removeClass(className.active) diff --git a/src/definitions/modules/dropdown.less b/src/definitions/modules/dropdown.less index 13f65ebae..6cf7606dd 100755 --- a/src/definitions/modules/dropdown.less +++ b/src/definitions/modules/dropdown.less @@ -616,18 +616,20 @@ select.ui.dropdown { /* Prompt Text */ .ui.multiple.dropdown > .text { - display: none; position: absolute; - top: auto; - left: auto; + top: 0; + left: 0; + padding: inherit; + margin: @multipleSelectionSearchMargin; + line-height: @searchSelectionLineHeight; } /* Input */ .ui.multiple.selection.dropdown > input.search { position: static; padding: 0; - width: @multipleSelectionSearchWidth; max-width: 100%; + width: @multipleSelectionSearchWidth; margin: @multipleSelectionSearchMargin; }