mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 22:10:21 +08:00
clean comment
This commit is contained in:
parent
3274723b1e
commit
3093a9e5d0
@ -131,7 +131,6 @@ function DynamicVirtualList<T>(props: DynamicVirtualListProps<T>) {
|
|||||||
|
|
||||||
const internalStickyRangeExtractor = useCallback(
|
const internalStickyRangeExtractor = useCallback(
|
||||||
(range: Range) => {
|
(range: Range) => {
|
||||||
// VSCode-like sticky behavior: show ancestor chain of current visible items
|
|
||||||
const activeStickies: number[] = []
|
const activeStickies: number[] = []
|
||||||
|
|
||||||
if (getItemDepth) {
|
if (getItemDepth) {
|
||||||
@ -298,14 +297,8 @@ function DynamicVirtualList<T>(props: DynamicVirtualListProps<T>) {
|
|||||||
position: isItemActiveSticky ? 'sticky' : 'absolute',
|
position: isItemActiveSticky ? 'sticky' : 'absolute',
|
||||||
top: isItemActiveSticky ? stickyOffset : 0,
|
top: isItemActiveSticky ? stickyOffset : 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
// Critical: Sticky items need higher z-index than non-sticky items
|
|
||||||
// Ancestors (lower activeStickyIndex) should have HIGHER z-index
|
|
||||||
// Non-sticky items get z-index 0 to ensure they render below sticky items
|
|
||||||
zIndex: isItemActiveSticky ? 1000 + (100 - activeStickyIndex) : isItemSticky ? 999 : 0,
|
zIndex: isItemActiveSticky ? 1000 + (100 - activeStickyIndex) : isItemSticky ? 999 : 0,
|
||||||
// CRITICAL: Disable pointer events for items covered by sticky headers
|
|
||||||
// This prevents hover/click events from bleeding through
|
|
||||||
pointerEvents: isCoveredBySticky ? 'none' : 'auto',
|
pointerEvents: isCoveredBySticky ? 'none' : 'auto',
|
||||||
// Add background and shadow for active sticky items
|
|
||||||
...(isItemActiveSticky && {
|
...(isItemActiveSticky && {
|
||||||
backgroundColor: 'var(--color-background)'
|
backgroundColor: 'var(--color-background)'
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -60,7 +60,6 @@ const NotesSidebar: FC<NotesSidebarProps> = ({
|
|||||||
const { activeNode } = useActiveNode(notesTree)
|
const { activeNode } = useActiveNode(notesTree)
|
||||||
const sortType = useAppSelector(selectSortType)
|
const sortType = useAppSelector(selectSortType)
|
||||||
|
|
||||||
// --- State ---
|
|
||||||
const [isShowStarred, setIsShowStarred] = useState(false)
|
const [isShowStarred, setIsShowStarred] = useState(false)
|
||||||
const [isShowSearch, setIsShowSearch] = useState(false)
|
const [isShowSearch, setIsShowSearch] = useState(false)
|
||||||
const [searchKeyword, setSearchKeyword] = useState('')
|
const [searchKeyword, setSearchKeyword] = useState('')
|
||||||
@ -72,13 +71,9 @@ const NotesSidebar: FC<NotesSidebarProps> = ({
|
|||||||
const trimmedSearchKeyword = useMemo(() => searchKeyword.trim(), [searchKeyword])
|
const trimmedSearchKeyword = useMemo(() => searchKeyword.trim(), [searchKeyword])
|
||||||
const hasSearchKeyword = trimmedSearchKeyword.length > 0
|
const hasSearchKeyword = trimmedSearchKeyword.length > 0
|
||||||
|
|
||||||
// --- Hooks ---
|
|
||||||
|
|
||||||
// Editing Hook
|
|
||||||
const { editingNodeId, renamingNodeIds, newlyRenamedNodeIds, inPlaceEdit, handleStartEdit, handleAutoRename } =
|
const { editingNodeId, renamingNodeIds, newlyRenamedNodeIds, inPlaceEdit, handleStartEdit, handleAutoRename } =
|
||||||
useNotesEditing({ onRenameNode })
|
useNotesEditing({ onRenameNode })
|
||||||
|
|
||||||
// Drag and Drop Hook
|
|
||||||
const {
|
const {
|
||||||
draggedNodeId,
|
draggedNodeId,
|
||||||
dragOverNodeId,
|
dragOverNodeId,
|
||||||
@ -90,13 +85,11 @@ const NotesSidebar: FC<NotesSidebarProps> = ({
|
|||||||
handleDragEnd
|
handleDragEnd
|
||||||
} = useNotesDragAndDrop({ onMoveNode })
|
} = useNotesDragAndDrop({ onMoveNode })
|
||||||
|
|
||||||
// File Upload Hook
|
|
||||||
const { handleDropFiles, handleSelectFiles, handleSelectFolder } = useNotesFileUpload({
|
const { handleDropFiles, handleSelectFiles, handleSelectFolder } = useNotesFileUpload({
|
||||||
onUploadFiles,
|
onUploadFiles,
|
||||||
setIsDragOverSidebar
|
setIsDragOverSidebar
|
||||||
})
|
})
|
||||||
|
|
||||||
// Menu Hook
|
|
||||||
const { getMenuItems } = useNotesMenu({
|
const { getMenuItems } = useNotesMenu({
|
||||||
renamingNodeIds,
|
renamingNodeIds,
|
||||||
onCreateNote,
|
onCreateNote,
|
||||||
@ -110,7 +103,6 @@ const NotesSidebar: FC<NotesSidebarProps> = ({
|
|||||||
activeNode
|
activeNode
|
||||||
})
|
})
|
||||||
|
|
||||||
// Search Hook
|
|
||||||
const searchOptions = useMemo(
|
const searchOptions = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
debounceMs: 300,
|
debounceMs: 300,
|
||||||
@ -132,14 +124,10 @@ const NotesSidebar: FC<NotesSidebarProps> = ({
|
|||||||
stats: searchStats
|
stats: searchStats
|
||||||
} = useFullTextSearch(searchOptions)
|
} = useFullTextSearch(searchOptions)
|
||||||
|
|
||||||
// --- Effects ---
|
|
||||||
|
|
||||||
// Sync notesTree to ref
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
notesTreeRef.current = notesTree
|
notesTreeRef.current = notesTree
|
||||||
}, [notesTree])
|
}, [notesTree])
|
||||||
|
|
||||||
// Trigger Search
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isShowSearch) {
|
if (!isShowSearch) {
|
||||||
reset()
|
reset()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user