mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
fix(skill-editor): select only filename stem when renaming files
Use setSelectionRange to exclude the file extension from the initial selection, matching the behavior of VS Code and Finder.
This commit is contained in:
parent
799d0c0d0b
commit
f0ba739e44
@ -19,8 +19,16 @@ const TreeEditInput = ({ node }: TreeEditInputProps) => {
|
||||
: t('skillSidebar.fileNamePlaceholder')
|
||||
|
||||
useEffect(() => {
|
||||
inputRef.current?.focus()
|
||||
inputRef.current?.select()
|
||||
const input = inputRef.current
|
||||
if (!input)
|
||||
return
|
||||
input.focus()
|
||||
const name = input.value
|
||||
const dotIndex = isFolder ? -1 : name.lastIndexOf('.')
|
||||
if (dotIndex > 0)
|
||||
input.setSelectionRange(0, dotIndex)
|
||||
else
|
||||
input.select()
|
||||
}, [])
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user