Skip to content

Commit bfecdf8

Browse files
⌥G (#118)
1 parent 62e397b commit bfecdf8

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"plasmo": "^0.84.2",
2525
"react": "^18.2.0",
2626
"react-dom": "^18.2.0",
27+
"react-hotkeys-hook": "^4.5.0",
2728
"validator": "^13.11.0",
2829
"webext-additional-permissions": "^2.4.0",
2930
"webext-content-scripts": "^2.5.5",

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/button/button.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import classNames from "classnames";
2-
import React, { useEffect, useMemo, useRef, useState } from "react";
2+
import { useEffect, useMemo, useRef, useState } from "react";
3+
import { useHotkeys } from "react-hotkeys-hook";
34
import Logo from "react:./logo-mark.svg";
45

56
import { useStorage } from "@plasmohq/storage/hook";
@@ -21,6 +22,8 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
2122
const [showDropdown, setShowDropdown] = useState(false);
2223
const [currentHref, setCurrentHref] = useState(window.location.href);
2324

25+
const linkRef = useRef<HTMLAnchorElement | null>(null);
26+
2427
useEffect(() => {
2528
const handleUrlChange = () => {
2629
setCurrentHref(window.location.href);
@@ -72,6 +75,10 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
7275
}
7376
}, [showDropdown]);
7477

78+
const target = openInNewTab ? "_blank" : "_self";
79+
80+
useHotkeys("alt+g", () => linkRef.current?.click(), [linkRef.current]);
81+
7582
return (
7683
<div
7784
id="gitpod-btn-nav"
@@ -82,8 +89,9 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
8289
<a
8390
className={classNames("button-part", disableAutostart ? "action-no-options" : "action")}
8491
href={actions[0].href}
85-
target={openInNewTab ? "_blank" : "_self"}
92+
target={target}
8693
rel="noreferrer"
94+
ref={linkRef}
8795
>
8896
<span className={classNames("action-label")}>
8997
<Logo className={classNames("action-logo")} width={14} height={14} />
@@ -121,7 +129,7 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
121129
ref={action === actions[1] ? firstActionRef : null}
122130
className={classNames("drop-down-action", "button-part")}
123131
href={action.href}
124-
target={openInNewTab ? "_blank" : "_self"}
132+
target={target}
125133
rel="noreferrer"
126134
>
127135
<span className={classNames("drop-down-label")}>{action.label}</span>

0 commit comments

Comments
 (0)