Skip to content

Commit

Permalink
Fix pressing Enter in a form (#3)
Browse files Browse the repository at this point in the history
* Fix pressing Enter in a form

* Update spatial_navigation.js

Co-authored-by: Mathieu Côté <[email protected]>

* Add const

---------

Co-authored-by: Mathieu Côté <[email protected]>
  • Loading branch information
massicottem and Boubalou authored Jul 30, 2024
1 parent 05647fd commit 1ea7009
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "spatial-navigation-js",
"description": "A javascript-based implementation of Spatial Navigation.",
"version": "1.1.1",
"version": "1.1.2",
"main": "spatial_navigation.js",
"homepage": "https://github.com/mirego/js-spatial-navigation#readme",
"repository": {
Expand Down
10 changes: 7 additions & 3 deletions spatial_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
'40': 'down'
};

var DEFAULT_SELECT_KEY_CODES = [13];
var ENTER_KEY_CODE = 13;

var DEFAULT_SELECT_KEY_CODES = [ENTER_KEY_CODE];

/************************/
/* Global Configuration */
Expand Down Expand Up @@ -863,8 +865,10 @@
if (!fireEvent(currentFocusedElement, 'enter-down')) {
return preventDefault();
}
preventDefault();
currentFocusedElement.click();
if (evt.keyCode !== ENTER_KEY_CODE) {
preventDefault();
currentFocusedElement.click();
}
}
}
return;
Expand Down

0 comments on commit 1ea7009

Please sign in to comment.