fix: focus-typing was not working while top buttons are focused
Massimo Melina committed
Sep 25, 2025 at 00:48 UTC
91f1c09fc764e272aaa5bb63dd918aaed0d9484b
1 file changed
+7
-5
frontend/src/BrowseFiles.ts
+7
-5
@@ -6,7 +6,8 @@ import {
6
} from 'react'
7
import { useEventListener, useMediaQuery, useWindowSize } from 'usehooks-ts'
8
import {
9
- domOn, ErrorMsg, hIcon, onlyTruthy, prefix, isMac, isCtrlKey, hfsEvent, formatTimestamp, restartAnimation
9
+ domOn, ErrorMsg, hIcon, onlyTruthy, prefix, isMac, isCtrlKey, hfsEvent, formatTimestamp, restartAnimation,
10
+ anyDialogOpen
11
} from './misc'
12
import { Checkbox, CustomCode, Bytes, iconBtn, Spinner } from './components'
13
import { Head } from './Head'
@@ -116,24 +117,25 @@ function FilesList() {
117
const navigate = useNavigate()
118
const timeout = useRef()
119
useEventListener('keydown', ev => {
119
- if (ev.target !== document.body && !(ev.target && ref.current?.contains(ev.target as any))) return
120
+ if (anyDialogOpen()) return // won't work while dialogs are open
121
if (isCtrlKey(ev as any) === 'Backspace' && location.pathname > '/')
122
return navigate(location.pathname + '..')
123
if (ev.metaKey || ev.ctrlKey || ev.altKey) return
124
const { key } = ev
124
- if (key === 'Tab' && focus) {
125
+ if (key === 'Tab' && focusIndex >= 0) { // tab key while we are already focusing will cycle over matching entries
126
const go = ev.shiftKey ? -1 : 1
127
setFocusSkip(was => {
128
if (go > 0 || was)
129
return was + go
130
endReached()
131
return was
131
- }) // we always try to go forward, and skip more, and if no enough matching items are found, we adjust "focusSkip" back
132
+ }) // we always try to go forward and skip more, and if no enough matching items are found, we adjust "focusSkip" back
133
renewTimeout()
134
ev.preventDefault()
135
return
136
}
137
if (key === ' ' && !focus) return
138
+ if ((ev.target as any)?.tagName?.match(/INPUT|TEXTAREA|SELECT/)) return
139
if (key.length === 1 || key === 'Backspace')
140
ev.preventDefault()
141
setFocus(was => {
@@ -365,7 +367,7 @@ const Entry = ({ entry, midnight, separator }: EntryProps) => {
367
const special = isMac ? ev.shiftKey : ev.metaKey
368
if (special && getShowComponent(entry))
369
return fileShow(entry, { startPlaying: true })
368
- openFileMenu(entry, ev, onlyTruthy([
370
+ void openFileMenu(entry, ev, onlyTruthy([
371
file_menu_on_link && 'open',
372
'delete',
373
'show'