Skip to content

Commit

Permalink
Merge pull request #5374 from storybooks/shortcut-blur-2
Browse files Browse the repository at this point in the history
Fix issue where "Tab" => [].
  • Loading branch information
ndelangen authored Jan 27, 2019
2 parents 6f4cf1c + cd47bc8 commit 12a9e75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/ui/src/libs/shortcut.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ describe('eventToShortcut', () => {
});
test('it handles enter key inputs', () => {
const output = eventToShortcut(ev({ key: 'Enter' }));
expect(output).toEqual([]);
expect(output).toEqual(null);
});
test('it handles tab key inputs', () => {
const output = eventToShortcut(ev({ key: 'Tab' }));
expect(output).toEqual(null);
});
test('it handles space bar inputs', () => {
const output = eventToShortcut(ev({ key: ' ' }));
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/libs/shortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const eventToShortcut = (e: KeyboardEvent): Shortcut | null => {
keys.push('ArrowLeft');
}

return keys;
return keys.length > 0 ? keys : null;
};

export const shortcutMatchesShortcut = (inputShortcut: Shortcut, shortcut: Shortcut): boolean => {
Expand Down

0 comments on commit 12a9e75

Please sign in to comment.