mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-27 19:34:38 +00:00
fix(webui): exclude file extension when selecting file name during inline rename (#285)
This commit is contained in:
@@ -17,6 +17,7 @@ import { EditableText } from '@/ui/components/ui/editable-text'
|
||||
import { ProgressCircle } from '@/ui/components/ui/progress-circle'
|
||||
import { Skeleton } from '@/ui/components/ui/skeleton'
|
||||
import { formatTimeAgo } from '@/ui/lib/time'
|
||||
import { selectFileNameWithoutExtension } from '@/ui/lib/rename-utils'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { useUploadStore } from '@/ui/stores/upload'
|
||||
import { useDraggable, useDroppable } from '@dnd-kit/react'
|
||||
@@ -188,8 +189,9 @@ export function FileCard({
|
||||
// the DOM has stabilized before focusing. Radix focus restoration
|
||||
// can sometimes conflict with immediate focus calls.
|
||||
const timeoutId = setTimeout(() => {
|
||||
inputRef.current?.focus()
|
||||
inputRef.current?.select()
|
||||
if (inputRef.current) {
|
||||
selectFileNameWithoutExtension(inputRef.current)
|
||||
}
|
||||
}, 150)
|
||||
return () => clearTimeout(timeoutId)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { File, Folder, MoreVertical, AudioLines } from 'lucide-react'
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { formatSize } from '@/ui/lib/format'
|
||||
import { selectFileNameWithoutExtension } from '@/ui/lib/rename-utils'
|
||||
import type { DragState } from '../dnd-types'
|
||||
import FieldRenderer from '../field-renderer'
|
||||
import { Badge } from '@/ui/components/ui/badge'
|
||||
@@ -133,8 +134,9 @@ export function FileListItem({
|
||||
// the DOM has stabilized before focusing. Radix focus restoration
|
||||
// can sometimes conflict with immediate focus calls.
|
||||
const timeoutId = setTimeout(() => {
|
||||
inputRef.current?.focus()
|
||||
inputRef.current?.select()
|
||||
if (inputRef.current) {
|
||||
selectFileNameWithoutExtension(inputRef.current)
|
||||
}
|
||||
}, 150)
|
||||
return () => clearTimeout(timeoutId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user