mirror of
https://github.com/langgenius/dify.git
synced 2026-04-21 03:07:39 +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:
@ -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>) => {
|
||||
|
||||
Reference in New Issue
Block a user