Skip to content

Commit 7b6136b

Browse files
authored
[devtools] Immediately set meta key in shortcut recorder (#82301)
1 parent 00261e9 commit 7b6136b

File tree

1 file changed

+9
-22
lines changed
  • packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/dev-tools-info

1 file changed

+9
-22
lines changed

packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/dev-tools-info/shortcut-recorder.tsx

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { JSX } from 'react'
2-
import { useState, useRef, useEffect } from 'react'
2+
import { useState, useRef } from 'react'
33
import { css } from '../../../../utils/css'
44

55
const SUCCESS_SHOW_DELAY_MS = 180
@@ -308,25 +308,13 @@ function parseKeyCode(code: string | JSX.Element) {
308308
}
309309

310310
function MetaKey() {
311-
// u00A0 =  
312-
const [label, setLabel] = useState('\u00A0')
313-
314-
const apple = isApple()
315-
316-
useEffect(() => {
317-
// Meta is Command on Apple devices, otherwise Control
318-
if (apple === true) {
319-
// eslint-disable-next-line react-hooks/set-state-in-effect -- TODO
320-
setLabel('⌘')
321-
}
322-
323-
// Explicitly say "Ctrl" instead of the symbol "⌃"
324-
// because most Windows/Linux laptops do not print the symbol
325-
// Other keyboard-intensive apps like Linear do this
326-
if (apple === false) {
327-
setLabel('Ctrl')
328-
}
329-
}, [apple])
311+
const label = isApple()
312+
? // Meta is Command on Apple devices, otherwise Control
313+
'⌘'
314+
: // Explicitly say "Ctrl" instead of the symbol "⌃"
315+
// because most Windows/Linux laptops do not print the symbol
316+
// Other keyboard-intensive apps like Linear do this
317+
'Ctrl'
330318

331319
return (
332320
<span style={{ minWidth: '1em', display: 'inline-block' }}>{label}</span>
@@ -499,8 +487,7 @@ export const SHORTCUT_RECORDER_STYLES = css`
499487
///////////////////////////////////////////////////////////////////////////////////////////////////
500488

501489
function testPlatform(re: RegExp): boolean | undefined {
502-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Checking on an unusual environment.
503-
return typeof window !== 'undefined' && window.navigator != null
490+
return window.navigator != null
504491
? re.test(window.navigator.platform)
505492
: undefined
506493
}

0 commit comments

Comments
 (0)