Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix(quicksearch): 2513 unhighlight, open on enter
Browse files Browse the repository at this point in the history
- remove ctrl+space listener (didn't work)
Closes #2513
  • Loading branch information
Christine Yu committed Jun 21, 2016
1 parent cd4f79c commit 1c1d8fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/scripts/components/facets/facets.controllers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ngApp.components.facets.controllers {
import IFilesService = ngApp.files.services.IFilesService;

enum KeyCode {
export enum KeyCode {
Space = 32,
Enter = 13,
Esc = 27,
Expand Down
30 changes: 8 additions & 22 deletions app/scripts/components/quick-search/quick-search.directives.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
module ngApp.components.quickSearch.directives {
enum KeyCode {
Space = 32,
Enter = 13,
Esc = 27,
Left = 37,
Right = 39,
Up = 38,
Down = 40,
Tab = 9
}
import KeyCode = ngApp.components.facets.controllers.KeyCode;

/* @ngInject */
function QuickSearch($uibModal: any, $window: ng.IWindowService, $uibModalStack): ng.IDirective {
Expand Down Expand Up @@ -43,19 +34,14 @@ module ngApp.components.quickSearch.directives {
};
},
link: function($scope, $element, attrs, ctrl) {
$element.on("click", function() {
const openAndBlur = () => {
ctrl.openModal();
});

angular.element($window.document).on("keypress", (e) => {
var validSpaceKeys = [
0, // Webkit
96 // Firefox
];

if (e.ctrlKey && validSpaceKeys.indexOf(e.which) !== -1) {
e.preventDefault();
ctrl.openModal();
$element.blur();
};
$element.on('click', openAndBlur);
$element.on('keypress', (e) => {
if (e.keyCode === KeyCode.Enter) {
openAndBlur();
}
});
}
Expand Down

0 comments on commit 1c1d8fd

Please sign in to comment.