Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: remove a lot of uneccesary code

Pedro Vítor Ribeiro Martinsfee3b33d1d20
diff --git a/packages/ui/src/components/Command/Command.utils.tsx b/packages/ui/src/components/Command/Command.utils.tsx
index 8bff8b8d96d..b916653ee7e 100644
--- a/packages/ui/src/components/Command/Command.utils.tsx
+++ b/packages/ui/src/components/Command/Command.utils.tsx
@@ -408,40 +408,16 @@ export function useAutoInputFocus() {
// Focus the input when typing from anywhere
React.useEffect(() => {
- function isModifierKey(event: KeyboardEvent) {
- const modifierKeys = ['Alt', 'Control', 'Meta', 'Tab']
- const { key } = event
- return modifierKeys.includes(key)
- }
-
- // Keep track of whether the modifier key (except shift) is pressed
- let modifierPressed = false
-
- function onKeyDown(event: KeyboardEvent) {
- // If the user is typing a modifier key, don't focus the input and set the modifierPressed flag
- if (isModifierKey(event)) {
- modifierPressed = true
- } else {
- if (!modifierPressed) {
- // Focus the input if no modifier key is pressed (other than shift)
- input?.focus()
- }
- }
- }
- function onKeyUp(event: KeyboardEvent) {
- console.log('keyup')
- if (isModifierKey(event)) {
- // Reset the modifierPressed flag when the modifier key is released
- modifierPressed = false
+ function onKeyDown(e: KeyboardEvent) {
+ if (!e.ctrlKey && !e.altKey && !e.metaKey && e.key !== 'Tab') {
+ input?.focus()
}
}
window.addEventListener('keydown', onKeyDown)
- window.addEventListener('keyup', onKeyUp)
return () => {
window.removeEventListener('keydown', onKeyDown)
- window.removeEventListener('keyup', onKeyUp)
}
}, [input])