Skip to content

Commit 5a7dc12

Browse files
committed
Fix typo this.isMac, added PropTypes.
1 parent d292f88 commit 5a7dc12

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

client/modules/IDE/hooks/useKeyDownHandlers.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import mapKeys from 'lodash/mapKeys';
2+
import PropTypes from 'prop-types';
23
import { useCallback, useEffect, useRef } from 'react';
34

45
/**
@@ -29,7 +30,7 @@ export default function useKeyDownHandlers(keyHandlers) {
2930
*/
3031
const handleEvent = useCallback((e) => {
3132
const isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1;
32-
const isCtrl = isMac ? e.metaKey && this.isMac : e.ctrlKey;
33+
const isCtrl = isMac ? e.metaKey : e.ctrlKey;
3334
if (e.shiftKey && isCtrl) {
3435
handlers.current[`ctrl-shift-${e.key.toLowerCase()}`]?.(e);
3536
}
@@ -48,8 +49,13 @@ export default function useKeyDownHandlers(keyHandlers) {
4849

4950
/**
5051
* Component version can be used in class components where hooks can't be used.
52+
*
53+
* @param {Record<string, (e: KeyboardEvent) => void>} handlers
5154
*/
5255
export const DocumentKeyDown = ({ handlers }) => {
5356
useKeyDownHandlers(handlers);
5457
return null;
5558
};
59+
DocumentKeyDown.propTypes = {
60+
handlers: PropTypes.objectOf(PropTypes.func)
61+
};

0 commit comments

Comments
 (0)