Browse Source

Fix overlap when selecting dropdown choice with keyboard when useLabels: false

pull/2308/merge
jlukic 9 years ago
parent
commit
40bf2cea35
1 changed files with 13 additions and 8 deletions
  1. 21
      src/definitions/modules/dropdown.js

21
src/definitions/modules/dropdown.js

@ -216,9 +216,8 @@ $.fn.dropdown = function(parameters) {
api: function() { api: function() {
var var
apiSettings = { apiSettings = {
debug : settings.debug,
cache : 'local',
on : false
debug : settings.debug,
on : false
} }
; ;
module.verbose('First request, initializing API'); module.verbose('First request, initializing API');
@ -562,8 +561,10 @@ $.fn.dropdown = function(parameters) {
queryRemote: function(query, callback) { queryRemote: function(query, callback) {
var var
apiSettings = { apiSettings = {
errorDuration : false,
urlData: {
errorDuration : false,
throttle : settings.throttle,
cache : 'local',
urlData : {
query: query query: query
}, },
onError: function() { onError: function() {
@ -589,7 +590,6 @@ $.fn.dropdown = function(parameters) {
apiSettings = $.extend(true, {}, apiSettings, settings.apiSettings); apiSettings = $.extend(true, {}, apiSettings, settings.apiSettings);
$module $module
.api('setting', apiSettings) .api('setting', apiSettings)
.api('abort')
.api('query') .api('query')
; ;
}, },
@ -896,6 +896,9 @@ $.fn.dropdown = function(parameters) {
isBubbledEvent = ($subMenu.find($target).length > 0) isBubbledEvent = ($subMenu.find($target).length > 0)
; ;
if(!isBubbledEvent && (!hasSubMenu || settings.allowCategorySelection)) { if(!isBubbledEvent && (!hasSubMenu || settings.allowCategorySelection)) {
if(!settings.useLabels) {
module.remove.searchTerm();
}
module.determine.selectAction.call(this, text, value); module.determine.selectAction.call(this, text, value);
} }
} }
@ -1049,6 +1052,7 @@ $.fn.dropdown = function(parameters) {
// enter (select or open sub-menu) // enter (select or open sub-menu)
if(pressedKey == keys.enter || pressedKey == keys.delimiter) { if(pressedKey == keys.enter || pressedKey == keys.delimiter) {
if(pressedKey == keys.enter && hasSelectedItem && hasSubMenu && !settings.allowCategorySelection) { if(pressedKey == keys.enter && hasSelectedItem && hasSubMenu && !settings.allowCategorySelection) {
module.verbose('Pressed enter on unselectable category, opening sub menu'); module.verbose('Pressed enter on unselectable category, opening sub menu');
pressedKey = keys.rightArrow; pressedKey = keys.rightArrow;
@ -1391,6 +1395,7 @@ $.fn.dropdown = function(parameters) {
var var
name = module.read.remoteData(value) name = module.read.remoteData(value)
; ;
module.verbose('Restoring value from session data', name, value);
remoteValues[value] = (name) remoteValues[value] = (name)
? name ? name
: value : value
@ -1635,7 +1640,6 @@ $.fn.dropdown = function(parameters) {
} }
}, },
values: function() { values: function() {
module.debug('Restoring selected values');
module.set.initialLoad(); module.set.initialLoad();
if(settings.apiSettings) { if(settings.apiSettings) {
if(settings.saveRemoteData) { if(settings.saveRemoteData) {
@ -2874,7 +2878,8 @@ $.fn.dropdown.settings = {
action : 'activate', // action on item selection (nothing, activate, select, combo, hide, function(){}) action : 'activate', // action on item selection (nothing, activate, select, combo, hide, function(){})
apiSettings : false, apiSettings : false,
saveRemoteData : false, // Whether remote name/value pairs should be stored in sessionStorage to allow remote data to be restored on page refresh
saveRemoteData : true, // Whether remote name/value pairs should be stored in sessionStorage to allow remote data to be restored on page refresh
throttle : 100, // How long to wait after last user input to search remotely
direction : 'auto', // Whether dropdown should always open in one direction direction : 'auto', // Whether dropdown should always open in one direction
keepOnScreen : true, // Whether dropdown should check whether it is on screen before showing keepOnScreen : true, // Whether dropdown should check whether it is on screen before showing

Loading…
Cancel
Save