Skip to content

Commit bab2048

Browse files
committed
Fixed issues mentioned in code review
1 parent af45423 commit bab2048

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

‎packages/publish-app-layer/src/index.tsx‎

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,26 @@ export default function () {
4747
}, []);
4848

4949
// keyboard shortcut for run and build
50-
const handleKeyPress = useCallback((event: { repeat: any; ctrlKey: boolean; key: string; }) => {
51-
if (!event.repeat && event.ctrlKey === true && event.key === "b")
52-
setShowPopup(!showPopup);
53-
callRunTaskApi();
54-
}, []);
55-
50+
const handleKeyPress = useCallback(
51+
(event: KeyboardEvent) => {
52+
const { repeat, ctrlKey, key, metaKey } = event;
53+
if (!repeat && ctrlKey === true && key === "b") {
54+
setShowPopup(!showPopup);
55+
callRunTaskApi();
56+
}
57+
58+
if (window.navigator && window.navigator.userAgent) {
59+
if (window.navigator.userAgent.indexOf("Mac")) {
60+
if (!repeat && metaKey === true && key === "b") {
61+
setShowPopup(!showPopup);
62+
callRunTaskApi();
63+
}
64+
}
65+
}
66+
},
67+
[callRunTaskApi, showPopup]
68+
);
69+
5670
// open http://localhost:4005
5771
const devWindow = useRef<Window | null>(null);
5872
useEffect(() => {
@@ -61,11 +75,11 @@ export default function () {
6175
devWindow.current = window.open("http://localhost:4005", "_blank");
6276
window.focus();
6377
}
64-
document.addEventListener('keydown', handleKeyPress);
78+
document.addEventListener("keydown", handleKeyPress);
6579
return () => {
66-
document.removeEventListener('keydown', handleKeyPress);
80+
document.removeEventListener("keydown", handleKeyPress);
6781
};
68-
}, [status,handleKeyPress]);
82+
}, [status, handleKeyPress]);
6983
return (
7084
<>
7185
<Menu name="PublishMenu" order={1}>

0 commit comments

Comments
 (0)