This repository was archived by the owner on Oct 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(uiSelectMultiple): ensure first item can selected #1713
Closed
Closed
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -97,6 +97,10 @@ describe('ui-select tests', function() { | |
}); | ||
}; | ||
|
||
scope.simple = { | ||
colors: ['Red', 'Green', 'Blue', 'Yellow', 'Magenta', 'Maroon', 'Umbra', 'Turquoise'], | ||
selected: ['Red'] | ||
}; | ||
|
||
scope.people = [ | ||
{ name: 'Adam', email: '[email protected]', group: 'Foo', age: 12 }, | ||
|
@@ -620,7 +624,7 @@ describe('ui-select tests', function() { | |
|
||
expect($(el).scope().$select.selected).not.toBeDefined(); | ||
}); | ||
|
||
it('should allow tagging if the attribute says so', function() { | ||
var el = createUiSelect({tagging: true}); | ||
clickMatch(el); | ||
|
@@ -1402,6 +1406,43 @@ describe('ui-select tests', function() { | |
expect($(el).scope().$select.selected).toEqual('idontexist'); | ||
}); | ||
|
||
it('should allow tagging with simple string and no label if attribute says so', function () { | ||
|
||
var el = compileTemplate( | ||
'<ui-select multiple tagging tagging-label="false" ng-model="simple.selected"> \ | ||
<ui-select-match placeholder="Pick one...">{{$select.selected}}</ui-select-match> \ | ||
<ui-select-choices repeat="color in simple.color | filter: $select.search"> \ | ||
<div ng-bind-html="color | highlight: $select.search"></div> \ | ||
</ui-select-choices> \ | ||
</ui-select>' | ||
); | ||
|
||
clickMatch(el); | ||
|
||
$(el).scope().$select.select("I don't exist"); | ||
|
||
expect($(el).scope().$select.selected).toEqual(["Red", "I don't exist"]); | ||
expect(scope.simple.selected).toEqual(['Red', "I don't exist"]) | ||
}); | ||
|
||
it('should not prevent selecting the first item when tagging with simple string and no label', function () { | ||
|
||
var el = compileTemplate( | ||
'<ui-select multiple tagging tagging-label="false" ng-model="simple.selected"> \ | ||
<ui-select-match placeholder="Pick one...">{{$item}}</ui-select-match> \ | ||
<ui-select-choices repeat="color in simple.colors | filter: $select.search"> \ | ||
<div ng-bind-html="color | highlight: $select.search"></div> \ | ||
</ui-select-choices> \ | ||
</ui-select>' | ||
); | ||
|
||
// ensure test source array has not changed | ||
expect(scope.simple.colors[1]).toBe('Green'); | ||
clickItem(el, 'Green'); | ||
|
||
expect(scope.simple.selected).toEqual(['Red', 'Green']); | ||
}); | ||
|
||
it('should allow creating tag on ENTER in multiple select mode with tagging enabled, no labels', function() { | ||
|
||
scope.taggingFunc = function (name) { | ||
|
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.
Can you save this $timeout to a variable so that onDestroy it can be cancelled?