Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit c7db0df

Browse files
dmatteopkozlowski-opensource
authored andcommitted
fix(typeahead): allow multiple line expression
introduce [\s\S]+ to include both whitespace and non whitespace characters Fixes #1687 Closes #1850
1 parent aa188ae commit c7db0df

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/typeahead/test/typeahead.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ describe('typeahead tests', function () {
150150
expect(inputEl.attr('aria-activedescendant')).toBeUndefined();
151151
});
152152

153+
it('should allow expressions over multiple lines', function () {
154+
var element = prepareInputEl('<div><input ng-model="result" typeahead="item for item in source \n' +
155+
'| filter:$viewValue"></div>');
156+
changeInputValueTo(element, 'ba');
157+
expect(element).toBeOpenWithActive(2, 0);
158+
159+
changeInputValueTo(element, '');
160+
expect(element).toBeClosed();
161+
});
162+
153163
it('should not open typeahead if input value smaller than a defined threshold', function () {
154164
var element = prepareInputEl('<div><input ng-model="result" typeahead="item for item in source | filter:$viewValue" typeahead-min-length="2"></div>');
155165
changeInputValueTo(element, 'b');

src/typeahead/typeahead.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
77
.factory('typeaheadParser', ['$parse', function ($parse) {
88

99
// 00000111000000000000022200000000000000003333333333333330000000000044000
10-
var TYPEAHEAD_REGEXP = /^\s*(.*?)(?:\s+as\s+(.*?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+(.*)$/;
10+
var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/;
1111

1212
return {
1313
parse:function (input) {

0 commit comments

Comments
 (0)