mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
0cde5be165
Convert React context providers to TypeScript [don't squash!] GitOrigin-RevId: d92a91798286978410956ab791d73c17c5086d86
27 lines
771 B
TypeScript
27 lines
771 B
TypeScript
import { useFileTreeSelectable } from '../contexts/file-tree-selectable'
|
|
import { FC, useCallback } from 'react'
|
|
|
|
const FileTreeInner: FC = ({ children }) => {
|
|
const { setIsRootFolderSelected, selectedEntityIds, select } =
|
|
useFileTreeSelectable()
|
|
|
|
const handleFileTreeClick = useCallback(() => {
|
|
setIsRootFolderSelected(true)
|
|
if (selectedEntityIds.size > 1) {
|
|
select([])
|
|
}
|
|
}, [select, selectedEntityIds.size, setIsRootFolderSelected])
|
|
|
|
return (
|
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
<div
|
|
className="file-tree-inner"
|
|
onClick={handleFileTreeClick}
|
|
data-testid="file-tree-inner"
|
|
>
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default FileTreeInner
|