Skip to content

Commit

Permalink
disable opacity set to zero cause of flickering when typing in ddl see (
Browse files Browse the repository at this point in the history
angular-ui#1298)

remove opacity change in dist

fix lost focus (on backspace or adding new tag) when append-to-body is used

fixing bug - when typing a letter that exists in one of the items in the ddl and then deleting it causes the (tag new item) to persists

fix bug: when using closeOnSelect with tagging - hitting the enter key sets the new tag but keeps the search input value

tagging:
--making sure no empty elements gets in on paste operation
--fix dupes search

added isNewTagDuplication optional user method to check if new tag (when using tagging where each tag is an object) already exists in the list

adding safety check that the control is still open cause _ensureHighlightVisible is called using a timeout

adding public to gitignore

ignoring public folder

fix tagging: when using 'tagging' (add tags on the fly) with refreshDelay, the keyup event fires before or after the 'refresh' (attr) method. added a fix to implement the refresh-delay for the keyup event as well

making sure new tag (tag added on the fly) is removed when already exists in the list of tags

fix bug when filtering

reverting back list folder (before fork state)
  • Loading branch information
onemenny committed Feb 10, 2016
1 parent 4467b82 commit 5ca372a
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 116 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/.idea
/.tmp
.DS_Store
public
22 changes: 11 additions & 11 deletions dist/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/


(function () {
(function () {
"use strict";

var KEY = {
Expand Down Expand Up @@ -284,7 +284,7 @@ uis.controller('uiSelectCtrl',
if (ctrl.searchInput.length !== 1) {
throw uiSelectMinErr('searchInput', "Expected 1 input.ui-select-search but got '{0}'.", ctrl.searchInput.length);
}

ctrl.isEmpty = function() {
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
};
Expand Down Expand Up @@ -388,7 +388,7 @@ uis.controller('uiSelectCtrl',
//If collection is an Object, convert it to Array

var originalSource = ctrl.parserResult.source;

//When an object is used as source, we better create an array and use it as 'source'
var createArrayFromObject = function(){
var origSrc = originalSource($scope);
Expand Down Expand Up @@ -434,7 +434,7 @@ uis.controller('uiSelectCtrl',
ctrl.items = [];
} else {
if (!angular.isArray(items)) {
throw uiSelectMinErr('items', "Expected an array but got '{0}'.", items);
throw uiSelectMinErr('items', "Expected an array but got '{0}'.", items);
} else {
//Remove already selected items (ex: while searching)
//TODO Should add a test
Expand Down Expand Up @@ -1181,7 +1181,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
$select = $scope.$select,
ngModel;

//Wait for link fn to inject it
//Wait for link fn to inject it
$scope.$evalAsync(function(){ ngModel = $scope.ngModel; });

ctrl.activeMatchIndex = -1;
Expand All @@ -1193,7 +1193,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec

ctrl.refreshComponent = function(){
//Remove already selected items
//e.g. When user clicks on a selection, the selected array changes and
//e.g. When user clicks on a selection, the selected array changes and
//the dropdown should remove that item
$select.refreshItems();
$select.sizeSearchInput();
Expand Down Expand Up @@ -1292,7 +1292,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
};
if (!inputValue) return resultMultiple; //If ngModel was undefined
for (var k = inputValue.length - 1; k >= 0; k--) {
//Check model array of currently selected items
//Check model array of currently selected items
if (!checkFnMultiple($select.selected, inputValue[k])){
//Check model array of all items available
if (!checkFnMultiple(data, inputValue[k])){
Expand All @@ -1303,8 +1303,8 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
}
return resultMultiple;
});
//Watch for external model changes

//Watch for external model changes
scope.$watchCollection(function(){ return ngModel.$modelValue; }, function(newValue, oldValue) {
if (oldValue != newValue){
ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters
Expand Down Expand Up @@ -1865,7 +1865,7 @@ uis.service('uisRepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinE

// if (isObjectCollection){
//00000000000000000000000000000111111111000000000000000222222222222220033333333333333333333330000444444444444444444000000000000000556666660000077777777777755000000000000000000000088888880000000
match = expression.match(/^\s*(?:([\s\S]+?)\s+as\s+)?(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+(([\w\.]+)?\s*(|\s*[\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
match = expression.match(/^\s*(?:([\s\S]+?)\s+as\s+)?(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+(([\w\.]+)?\s*(|\s*[\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);

// 1 Alias
// 2 Item
Expand Down Expand Up @@ -1899,7 +1899,7 @@ uis.service('uisRepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinE
expression += ' track by ' + this.trackByExp;
}
return expression;
}
}
};

};
Expand Down
27 changes: 22 additions & 5 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,17 @@ uis.controller('uiSelectCtrl',
// Debounce
// See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L155
// FYI AngularStrap typeahead does not have debouncing: https://github.com/mgcrea/angular-strap/blob/v2.0.0-rc.4/src/typeahead/typeahead.js#L177
if (_refreshDelayPromise) {
$timeout.cancel(_refreshDelayPromise);
if (ctrl.refreshDelay > 0) {
if (_refreshDelayPromise) {
$timeout.cancel(_refreshDelayPromise);
}
_refreshDelayPromise = $timeout(function () {
$scope.$eval(refreshAttr);
}, ctrl.refreshDelay);
}
_refreshDelayPromise = $timeout(function() {
else {
$scope.$eval(refreshAttr);
}, ctrl.refreshDelay);
}
}
};

Expand Down Expand Up @@ -305,7 +310,12 @@ uis.controller('uiSelectCtrl',
}
}
// search ctrl.selected for dupes potentially caused by tagging and return early if found
if ( ctrl.selected && angular.isArray(ctrl.selected) && ctrl.selected.filter( function (selection) { return angular.equals(selection, item); }).length > 0 ) {
if (ctrl.selected && angular.isArray(ctrl.selected) && ctrl.selected.filter(function (selection) {
return ctrl.isNewTagDuplication !== angular.noop ? ctrl.isNewTagDuplication($scope, {
newItem: item,
existingItem: angular.copy(selection)
}) : angular.equals(angular.copy(selection), item);
}).length > 0) {
ctrl.close(skipFocusser);
return;
}
Expand All @@ -326,6 +336,9 @@ uis.controller('uiSelectCtrl',
if (ctrl.closeOnSelect) {
ctrl.close(skipFocusser);
}
else {
_resetSearchInput();
}
if ($event && $event.type === 'click') {
ctrl.clickTriggeredSelect = true;
}
Expand Down Expand Up @@ -496,6 +509,7 @@ uis.controller('uiSelectCtrl',
var data = e.originalEvent.clipboardData.getData('text/plain');
if (data && data.length > 0 && ctrl.taggingTokens.isActivated && ctrl.tagging.fct) {
var items = data.split(ctrl.taggingTokens.tokens[0]); // split by first token only
items = items.filter(Boolean);
if (items && items.length > 0) {
angular.forEach(items, function (item) {
var newItem = ctrl.tagging.fct(item);
Expand All @@ -517,6 +531,9 @@ uis.controller('uiSelectCtrl',

// See https://github.com/ivaynberg/select2/blob/3.4.6/select2.js#L1431
function _ensureHighlightVisible() {
if (!ctrl.open) {
return;
}
var container = $element.querySelectorAll('.ui-select-choices-content');
var choices = container.querySelectorAll('.ui-select-choices-row');
if (choices.length < 1) {
Expand Down
5 changes: 4 additions & 1 deletion src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ uis.directive('uiSelect',

$select.onSelectCallback = $parse(attrs.onSelect);
$select.onRemoveCallback = $parse(attrs.onRemove);
$select.isNewTagDuplication = $parse(attrs.isNewTagDuplication);

//Limit the number of selections allowed
$select.limit = (angular.isDefined(attrs.limit)) ? parseInt(attrs.limit, 10) : undefined;
Expand Down Expand Up @@ -253,6 +254,8 @@ uis.directive('uiSelect',
element[0].style.left = '';
element[0].style.top = '';
element[0].style.width = originalWidth;

$select.setFocus();
}

// Hold on to a reference to the .ui-select-dropdown element for direction support.
Expand Down Expand Up @@ -300,7 +303,7 @@ uis.directive('uiSelect',
}

// Hide the dropdown so there is no flicker until $timeout is done executing.
dropdown[0].style.opacity = 0;
//dropdown[0].style.opacity = 0;

// Delay positioning the dropdown until all choices have been added so its height is correct.
$timeout(function(){
Expand Down
Loading

0 comments on commit 5ca372a

Please sign in to comment.