Skip to content

Commit

Permalink
Merge pull request #761 from ICRAR/eagle-1331
Browse files Browse the repository at this point in the history
EAGLE-1331: Fix bug where QuickActions with no keyboard shortcut would still display "[]"
  • Loading branch information
james-strauss-uwa authored Nov 7, 2024
2 parents 7fb3e9d + c2955ec commit 7b81a7a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/KeyboardShortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export class KeyboardShortcut {
texts.push(result);
}

// if there are no key texts produced, then it doesn't make sense to return "[]",
// just return an empty string
if (texts.length === 0){
return "";
}

// surround with brackets if required
if (addBrackets){
return "[ " + texts.join(', ') + " ]";
Expand Down Expand Up @@ -128,11 +134,11 @@ export class KeyboardShortcut {
}

static QUICK_ACTION(id: string, name: string, tags: string[], run: (eagle: Eagle, event: KeyboardEvent) => void): KeyboardShortcut {
return new KeyboardShortcut(id, name, [new Key("")], "keydown", true, false, tags, KeyboardShortcut.true, KeyboardShortcut.false, KeyboardShortcut.true, run);
return new KeyboardShortcut(id, name, [], "keydown", true, false, tags, KeyboardShortcut.true, KeyboardShortcut.false, KeyboardShortcut.true, run);
}

static QUICK_ACTION_DOCS(id: string, name: string, tags: string[], url: string): KeyboardShortcut {
return new KeyboardShortcut(id, name, [new Key("")], "keydown", true, false, tags, KeyboardShortcut.true, KeyboardShortcut.false, KeyboardShortcut.true, (eagle): void => {QuickActions.quickOpenDocsLink(url);});
return new KeyboardShortcut(id, name, [], "keydown", true, false, tags, KeyboardShortcut.true, KeyboardShortcut.false, KeyboardShortcut.true, (eagle): void => {QuickActions.quickOpenDocsLink(url);});
}

static processKey(e: KeyboardEvent) : void {
Expand Down

0 comments on commit 7b81a7a

Please sign in to comment.