Skip to content

Commit

Permalink
File Viewer Tree Example: behavior of SPACE changed to be the same as…
Browse files Browse the repository at this point in the history
… RETURN in tree
  • Loading branch information
howard-e committed Nov 15, 2021
1 parent f623ddb commit 8c0e9fb
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions examples/treeview/treeview-1/js/treeitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,8 @@ Treeitem.prototype.isExpanded = function () {
/* EVENT HANDLERS */

Treeitem.prototype.handleKeydown = function (event) {
var tgt = event.currentTarget,
flag = false,
char = event.key,
clickEvent;
var flag = false,
char = event.key;

function isPrintableCharacter(str) {
return str.length === 1 && str.match(/\S/);
Expand Down Expand Up @@ -132,6 +130,7 @@ Treeitem.prototype.handleKeydown = function (event) {
} else {
switch (event.keyCode) {
case this.keyCode.RETURN:
case this.keyCode.SPACE:
var treeitem = event.currentTarget;
var label = treeitem.getAttribute('aria-label');
if (!label) {
Expand All @@ -145,18 +144,6 @@ Treeitem.prototype.handleKeydown = function (event) {
flag = true;
break;

case this.keyCode.SPACE:
// Create simulated mouse event to mimic the behavior of ATs
// and let the event handler handleClick do the housekeeping.
clickEvent = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true,
});
tgt.dispatchEvent(clickEvent);
flag = true;
break;

case this.keyCode.UP:
this.tree.setFocusToPreviousItem(this);
flag = true;
Expand Down

0 comments on commit 8c0e9fb

Please sign in to comment.