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

Fix: issue #877 Typing fast in firefox skips the second character #1785

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ uis.controller('uiSelectCtrl',
if (!ctrl.disabled && !ctrl.open) {
if(!avoidReset) _resetSearchInput();

$scope.$broadcast('uis:activate');

ctrl.open = true;

ctrl.activeIndex = ctrl.activeIndex >= ctrl.items.length ? 0 : ctrl.activeIndex;
Expand All @@ -131,13 +129,13 @@ uis.controller('uiSelectCtrl',
// Only focus input after the animation has finished
ctrl.$animate.off('removeClass', searchInput[0], animateHandler);
$timeout(function () {
ctrl.focusSearchInput(initSearchValue);
ctrl.focusSearchInput();
});
} else if (phase === 'close') {
// Only focus input after the animation has finished
ctrl.$animate.off('enter', container[0], animateHandler);
$timeout(function () {
ctrl.focusSearchInput(initSearchValue);
ctrl.focusSearchInput();
});
}
};
Expand All @@ -149,7 +147,7 @@ uis.controller('uiSelectCtrl',
}
} else {
$timeout(function () {
ctrl.focusSearchInput(initSearchValue);
ctrl.focusSearchInput();
if(!ctrl.tagging.isActivated && ctrl.items.length > 1) {
_ensureHighlightVisible();
}
Expand All @@ -162,9 +160,16 @@ uis.controller('uiSelectCtrl',
}
};

ctrl.focusSearchInput = function (initSearchValue) {
ctrl.search = initSearchValue || ctrl.search;
ctrl.initSearch = function(searchValue) {
ctrl.search = searchValue || ctrl.search;
};

ctrl.focusSearchInput = function () {
ctrl.searchInput[0].focus();
if (ctrl.focusser) {
ctrl.focusser.trigger('blur'); // in all browsers but IE the focus causes a blur, for IEs sake force a blur
}
$scope.$broadcast('uis:activate');
};

ctrl.findGroupByName = function(name) {
Expand Down Expand Up @@ -423,7 +428,7 @@ uis.controller('uiSelectCtrl',
ctrl.close(skipFocusser);
return;
}
}
}
_resetSearchInput();
$scope.$broadcast('uis:select', item);

Expand Down
7 changes: 5 additions & 2 deletions src/uiSelectSingleDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ uis.directive('uiSelectSingle', ['$timeout','$compile', function($timeout, $comp
$select.focus = true;
});
});

focusser.bind("blur", function(){
scope.$evalAsync(function(){
$select.focus = false;
$select.initSearch(focusser.val());
focusser.val('');
});
});

focusser.bind("keydown", function(e){

if (e.which === KEY.BACKSPACE) {
Expand Down Expand Up @@ -112,8 +116,7 @@ uis.directive('uiSelectSingle', ['$timeout','$compile', function($timeout, $comp
return;
}

$select.activate(focusser.val()); //User pressed some regular key, so we pass it to the search input
focusser.val('');
$select.activate(); //User pressed some regular key, so we activate the search input
scope.$digest();

});
Expand Down