File tree Expand file tree Collapse file tree
src/components/routes/webdav/components/dialog Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "private" : true ,
33 "type" : " module" ,
4- "version" : " 1.0.6 " ,
4+ "version" : " 1.0.7 " ,
55 "scripts" : {
66 "dev" : " vite" ,
77 "build" : " vite build" ,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import {dialogList} from "../../../../../utils/DialogContainer.jsx";
55import { moveFile } from "../../utils/WebDavUtils.jsx" ;
66import useProxyState from "../../../../../hooks/useProxyState.js" ;
77import LoadingButton from "../../../../common/base/LoadingButton.jsx" ;
8+ import { useEffect , useId } from "react" ;
89
910function RenameFile ( { path, name} ) {
1011
@@ -13,14 +14,37 @@ function RenameFile({path, name}) {
1314 overwrite : false ,
1415 } )
1516
17+
18+ const inputId = useId ( )
19+
1620 const { newName, overwrite} = state ;
1721
22+ useEffect ( ( ) => {
23+ const input = document . querySelector ( `#${ inputId } ` )
24+ if ( ! input ) {
25+ return
26+ }
27+ input . focus ( ) ;
28+
29+ const value = input . value ;
30+
31+ const dotIndex = value . lastIndexOf ( '.' ) ;
32+
33+
34+ if ( dotIndex === - 1 ) {
35+ input . setSelectionRange ( 0 , value . length ) ;
36+ } else {
37+ input . setSelectionRange ( 0 , dotIndex ) ;
38+ }
39+ } , [ ] )
40+
1841
1942 return (
2043 < DialogDiv className = { 'shadow' } >
2144 < h4 className = { 'no-select' } > 重命名文件</ h4 >
2245 < div class = "content" >
2346 < TextField
47+ id = { inputId }
2448 label = { '文件名称' }
2549 variant = { 'outlined' }
2650 value = { newName }
You can’t perform that action at this time.
0 commit comments