1
1
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" ;
3
4
import Logo from "react:./logo-mark.svg" ;
4
5
5
6
import { useStorage } from "@plasmohq/storage/hook" ;
@@ -21,6 +22,8 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
21
22
const [ showDropdown , setShowDropdown ] = useState ( false ) ;
22
23
const [ currentHref , setCurrentHref ] = useState ( window . location . href ) ;
23
24
25
+ const linkRef = useRef < HTMLAnchorElement | null > ( null ) ;
26
+
24
27
useEffect ( ( ) => {
25
28
const handleUrlChange = ( ) => {
26
29
setCurrentHref ( window . location . href ) ;
@@ -72,6 +75,10 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
72
75
}
73
76
} , [ showDropdown ] ) ;
74
77
78
+ const target = openInNewTab ? "_blank" : "_self" ;
79
+
80
+ useHotkeys ( "alt+g" , ( ) => linkRef . current ?. click ( ) , [ linkRef . current ] ) ;
81
+
75
82
return (
76
83
< div
77
84
id = "gitpod-btn-nav"
@@ -82,8 +89,9 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
82
89
< a
83
90
className = { classNames ( "button-part" , disableAutostart ? "action-no-options" : "action" ) }
84
91
href = { actions [ 0 ] . href }
85
- target = { openInNewTab ? "_blank" : "_self" }
92
+ target = { target }
86
93
rel = "noreferrer"
94
+ ref = { linkRef }
87
95
>
88
96
< span className = { classNames ( "action-label" ) } >
89
97
< Logo className = { classNames ( "action-logo" ) } width = { 14 } height = { 14 } />
@@ -121,7 +129,7 @@ export const GitpodButton = ({ application, additionalClassNames }: GitpodButton
121
129
ref = { action === actions [ 1 ] ? firstActionRef : null }
122
130
className = { classNames ( "drop-down-action" , "button-part" ) }
123
131
href = { action . href }
124
- target = { openInNewTab ? "_blank" : "_self" }
132
+ target = { target }
125
133
rel = "noreferrer"
126
134
>
127
135
< span className = { classNames ( "drop-down-label" ) } > { action . label } </ span >
0 commit comments