This repository was archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat(typeahead): handles min-length of 0 #1624
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,8 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap | |
//SUPPORTED ATTRIBUTES (OPTIONS) | ||
|
||
//minimal no of characters that needs to be entered before typeahead kicks-in | ||
var minSearch = originalScope.$eval(attrs.typeaheadMinLength) || 1; | ||
var minSearch = originalScope.$eval(attrs.typeaheadMinLength); | ||
minSearch = minSearch === 0 ? minSearch : minSearch || 1; | ||
|
||
//minimal wait time after last character typed before typehead kicks-in | ||
var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0; | ||
|
@@ -150,7 +151,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap | |
|
||
hasFocus = true; | ||
|
||
if (inputValue && inputValue.length >= minSearch) { | ||
if (minSearch === 0 || inputValue && inputValue.length >= minSearch) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there check for invalid inputs here (line 44) - strings, numbers as strings, negative numbers ...? Maybe new tests to take care of invalid inputs, to be on the safe side? |
||
if (waitTime > 0) { | ||
if (timeoutPromise) { | ||
$timeout.cancel(timeoutPromise);//cancel previous timeout | ||
|
@@ -221,7 +222,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap | |
|
||
resetMatches(); | ||
|
||
//return focus to the input element if a mach was selected via a mouse click event | ||
//return focus to the input element if a match was selected via a mouse click event | ||
element[0].focus(); | ||
}; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it not also check if the
input
isfocus
'd?Otherwise any
typeahead
directive would stay open?