11import Link from 'next/link'
2- import { FC , useCallback } from 'react'
2+ import { FC , useCallback , useRef } from 'react'
33import { NoteCacheItem } from 'libs/web/cache'
44import MarkText from 'components/portal/filter-modal/mark-text'
55import IconButton from 'components/icon-button'
66import HotkeyTooltip from 'components/hotkey-tooltip'
77import TrashState from 'libs/web/state/trash'
88import PortalState from 'libs/web/state/portal'
99import useI18n from 'libs/web/hooks/use-i18n'
10+ import classNames from 'classnames'
11+ import useScrollView from 'libs/web/hooks/use-scroll-view'
1012
1113const TrashItem : FC < {
1214 note : NoteCacheItem
1315 keyword ?: string
14- } > = ( { note, keyword } ) => {
16+ selected ?: boolean
17+ } > = ( { note, keyword, selected } ) => {
1518 const { t } = useI18n ( )
1619 const { restoreNote, deleteNote, filterNotes } = TrashState . useContainer ( )
1720 const {
1821 trash : { close } ,
1922 } = PortalState . useContainer ( )
23+ const ref = useRef < HTMLLIElement > ( null )
2024
2125 const onClickRestore = useCallback ( async ( ) => {
2226 await restoreNote ( note )
@@ -28,9 +32,16 @@ const TrashItem: FC<{
2832 filterNotes ( keyword )
2933 } , [ deleteNote , note . id , filterNotes , keyword ] )
3034
35+ useScrollView ( ref , selected )
36+
3137 return (
32- < li className = "hover:bg-gray-200 cursor-pointer py-2 px-4 flex" >
33- < Link href = { `/${ note . id } ` } >
38+ < li
39+ ref = { ref }
40+ className = { classNames ( 'hover:bg-gray-200 cursor-pointer py-2 px-4 flex' , {
41+ 'bg-gray-300' : selected ,
42+ } ) }
43+ >
44+ < Link href = { `/${ note . id } ` } shallow >
3445 < a className = " block text-xs text-gray-500 flex-grow" onClick = { close } >
3546 < h4 className = "text-sm font-bold" >
3647 < MarkText text = { note . title } keyword = { keyword } />
0 commit comments