Skip to content

Commit

Permalink
Add #3886 min characters for dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Apr 13, 2016
1 parent db79ded commit 544b205
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

**Enhancements**
- **Site** - Added colored box shadow defaults. `ui message` now includes individual colored border shadows based on new site defaults.
- **Dropdown** - Adds new setting `minCharacters` which sets the minimum number of characters required to start filtering results #3886
- **Dropdown** - Added `1px` offset for current text so that the text position cursor does not overlap first pixel of text.
- **Dropdown** - Added new convenience method `restore placeholder text`
- **Rating** - Added new setting `fireOnInit` for rating, which defaults to `false`. When set to true `onRate` will fire when rating is initialized #3712
Expand Down
18 changes: 17 additions & 1 deletion src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,12 @@ $.fn.dropdown = function(parameters) {
: module.get.query()
;
module.verbose('Searching for query', query);
module.filter(query);
if(module.has.minCharacters(query)) {
module.filter(query);
}
else {
module.hide();
}
},

select: {
Expand Down Expand Up @@ -2797,6 +2802,16 @@ $.fn.dropdown = function(parameters) {
selectInput: function() {
return ( $input.is('select') );
},
minCharacters: function(searchTerm) {
if(settings.minCharacters) {
searchTerm = (searchTerm !== undefined)
? String(searchTerm)
: String(module.get.query())
;
return (searchTerm.length >= settings.minCharacters);
}
return true;
},
firstLetter: function($item, letter) {
var
text,
Expand Down Expand Up @@ -3356,6 +3371,7 @@ $.fn.dropdown.settings = {


apiSettings : false,
minCharacters : 1, // 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

Expand Down

0 comments on commit 544b205

Please sign in to comment.