overleaf/services/web/frontend/js/features/file-tree/components/file-tree-inner.tsx
Alf Eaton b9a6e7009d Improve context menu behaviour in the file tree (#15142)
* Tidy up menu button
* Unselect all items when clicking in the file tree root
* Close the context menu when selecting a new item
* Avoid selecting multiple items with Ctrl+click on macOS

GitOrigin-RevId: b67a724909668ec13d7a6d09ffc31574cb42238f
2023-10-13 08:03:26 +00:00

27 lines
715 B
TypeScript

import { useFileTreeSelectable } from '../contexts/file-tree-selectable'
import { useCallback } from 'react'
type FileTreeInnerProps = {
children: React.ReactNode
}
function FileTreeInner({ children }: FileTreeInnerProps) {
const { setIsRootFolderSelected } = useFileTreeSelectable()
const handleFileTreeClick = useCallback(() => {
setIsRootFolderSelected(true)
}, [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