feat: add rename input focus handling in FileManager component
This commit is contained in:
parent
8ea3e3bc3c
commit
b18f9c685b
|
|
@ -102,6 +102,7 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
|
|||
const [renameName, setRenameName] = useState('');
|
||||
const [mountEntry, setMountEntry] = useState<EntryInfo | null>(null);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const renameInputRef = useRef<HTMLInputElement>(null);
|
||||
const dragCounter = useRef(0);
|
||||
|
||||
const load = useCallback(async (p: string) => {
|
||||
|
|
@ -270,6 +271,7 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
|
|||
setRenameEntry(entry);
|
||||
setRenameName(entry.name);
|
||||
setActionEntry(null);
|
||||
setTimeout(() => renameInputRef.current?.focus(), 50);
|
||||
};
|
||||
|
||||
const commitRename = async () => {
|
||||
|
|
@ -607,6 +609,7 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa
|
|||
if (e.key === 'Escape') setRenameEntry(null);
|
||||
}}
|
||||
onBlur={() => void commitRename()}
|
||||
ref={renameInputRef}
|
||||
onClick={e => e.stopPropagation()}
|
||||
onFocus={e => {
|
||||
const dotIdx = renameName.lastIndexOf('.');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user