Skip to content

Commit

Permalink
Finally fixes #2058, forceSelection shouldnt occur on empty query. mi…
Browse files Browse the repository at this point in the history
…nor formatting
  • Loading branch information
jlukic committed Aug 11, 2015
1 parent 49e03b3 commit 7a93ac2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- **Modal** - Increased `close` specificity, modal will now only close on `> .close` #2736
- **Transition** - Transition callbacks now all have the correct `this` set. #2758
- **Dropdown** - Fix `left menu` inside `ui menu` appearing horizontally #2778
- **Dropdown** - `forceSelection` no longer sets current value in search selection when current query is blank #2058

**Additional Bugs**
- **Build Tools** - Fixes issue on `win` platform where packaged theme would not correctly update when using watch due to regExp not matching windows path separators.
Expand Down
23 changes: 15 additions & 8 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ $.fn.dropdown = function(parameters) {
beginsWithRegExp = new RegExp('^' + escapedTerm, 'igm')
;
// avoid loop if we're matching nothing
if(searchTerm === '') {
if( !module.has.query() ) {
$results = $item;
}
else {
Expand Down Expand Up @@ -771,7 +771,7 @@ $.fn.dropdown = function(parameters) {
: $activeItem,
hasSelected = ($selectedItem.size() > 0)
;
if(hasSelected) {
if( hasSelected && module.has.query() ) {
module.debug('Forcing partial selection to selected item', $selectedItem);
module.event.item.click.call($selectedItem);
}
Expand Down Expand Up @@ -909,7 +909,9 @@ $.fn.dropdown = function(parameters) {
touch: function(event) {
module.determine.eventOnElement(event, function() {
if(event.type == 'touchstart') {
module.timer = setTimeout(module.hide, settings.delay.touch);
module.timer = setTimeout(function() {
module.hide();
}, settings.delay.touch);
}
else if(event.type == 'touchmove') {
clearTimeout(module.timer);
Expand Down Expand Up @@ -959,15 +961,17 @@ $.fn.dropdown = function(parameters) {
}, settings.delay.hide);
}
},
touchend: function() {
},
click: function (event) {
var
$choice = $(this),
$target = (event)
$choice = $(this),
$target = (event)
? $(event.target)
: $(''),
$subMenu = $choice.find(selector.menu),
text = module.get.choiceText($choice),
value = module.get.choiceValue($choice, text),
$subMenu = $choice.find(selector.menu),
text = module.get.choiceText($choice),
value = module.get.choiceValue($choice, text),
hasSubMenu = ($subMenu.length > 0),
isBubbledEvent = ($subMenu.find($target).length > 0)
;
Expand Down Expand Up @@ -2656,6 +2660,9 @@ $.fn.dropdown = function(parameters) {
allResultsFiltered: function() {
return ($item.filter(selector.unselectable).length === $item.length);
},
query: function() {
return (module.get.query() != '');
},
value: function(value) {
var
values = module.get.values(),
Expand Down

0 comments on commit 7a93ac2

Please sign in to comment.