-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4925 from voxel51/fix/shortcuts
fix shortcuts crashing + add next/previous shortcuts in help modal
- Loading branch information
Showing
6 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { shortcutToHelpItems } from "./utils"; | ||
|
||
describe("shortcut processing test", () => { | ||
it("parses unique shortcuts", () => { | ||
const results = shortcutToHelpItems({ | ||
one: { shortcut: "test" }, | ||
two: { shortcut: "test" }, | ||
}); | ||
expect(results).toStrictEqual([{ shortcut: "test" }]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
export function shortcutToHelpItems(SHORTCUTS) { | ||
const result = {}; | ||
for (const k of SHORTCUTS) { | ||
result[SHORTCUTS[k].shortcut] = SHORTCUTS[k]; | ||
interface ShortcutItem { | ||
shortcut: string; | ||
} | ||
|
||
type Shortcuts = { [key: string]: ShortcutItem }; | ||
|
||
export function shortcutToHelpItems(SHORTCUTS: Shortcuts) { | ||
const uniqueItems = {}; | ||
for (const item of Object.values(SHORTCUTS)) { | ||
uniqueItems[item.shortcut] = item; | ||
} | ||
return Object.values(result); | ||
return Object.values(uniqueItems); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters