Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(list): fix key hijacking
Browse files Browse the repository at this point in the history
closes #2318
  • Loading branch information
rschmukler committed Apr 16, 2015
1 parent e0d9831 commit e1ca13f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function mdListDirective($mdTheming) {
* </hljs>
*
*/
function mdListItemDirective($mdAria) {
function mdListItemDirective($mdAria, $mdConstant) {
var proxiedTypes = ['md-checkbox', 'md-switch'];
return {
restrict: 'E',
Expand Down Expand Up @@ -187,10 +187,12 @@ function mdListItemDirective($mdAria) {

if (!$element[0].firstElementChild.hasAttribute('ng-click') && !proxies.length) {
$element[0].firstElementChild.addEventListener('keypress', function(e) {
if (e.keyCode == 13 || e.keyCode == 32) {
$element[0].firstElementChild.click();
e.preventDefault();
e.stopPropagation();
if (e.target.nodeName != 'INPUT') {
if (e.keyCode == $mdConstant.KEY_CODE.SPACE) {
$element[0].firstElementChild.click();
e.preventDefault();
e.stopPropagation();
}
}
});
}
Expand Down

0 comments on commit e1ca13f

Please sign in to comment.