|
|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useEffect } from 'react'
|
|
|
+import React, { useEffect, useState } from 'react'
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
import withErrorBoundary from '../../../infrastructure/error-boundary'
|
|
|
@@ -31,6 +31,17 @@ const FileTreeRoot = React.memo(function FileTreeRoot({
|
|
|
const { _id: projectId } = useProjectContext(projectContextPropTypes)
|
|
|
const { fileTreeData } = useFileTreeData()
|
|
|
const isReady = projectId && fileTreeData
|
|
|
+ const [shouldShowVisualSelection, setShouldShowVisualSelection] =
|
|
|
+ useState(true)
|
|
|
+
|
|
|
+ const handleFileTreeClick = e => {
|
|
|
+ if (e.target.classList.contains('bottom-buffer')) {
|
|
|
+ setShouldShowVisualSelection(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ setShouldShowVisualSelection(e.target !== e.currentTarget)
|
|
|
+ }
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (isReady) onInit()
|
|
|
@@ -48,8 +59,15 @@ const FileTreeRoot = React.memo(function FileTreeRoot({
|
|
|
{isConnected ? null : <div className="disconnected-overlay" />}
|
|
|
<FileTreeToolbar />
|
|
|
<FileTreeContextMenu />
|
|
|
- <div className="file-tree-inner">
|
|
|
- <FileTreeRootFolder />
|
|
|
+ {/* 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"
|
|
|
+ >
|
|
|
+ <FileTreeRootFolder
|
|
|
+ shouldShowVisualSelection={shouldShowVisualSelection}
|
|
|
+ />
|
|
|
</div>
|
|
|
<FileTreeModalDelete />
|
|
|
<FileTreeModalCreateFile />
|
|
|
@@ -59,7 +77,7 @@ const FileTreeRoot = React.memo(function FileTreeRoot({
|
|
|
)
|
|
|
})
|
|
|
|
|
|
-function FileTreeRootFolder() {
|
|
|
+function FileTreeRootFolder({ shouldShowVisualSelection }) {
|
|
|
useFileTreeSocketListener()
|
|
|
const { fileTreeData } = useFileTreeData()
|
|
|
|
|
|
@@ -75,6 +93,7 @@ function FileTreeRootFolder() {
|
|
|
classes={{ root: 'file-tree-list' }}
|
|
|
dropRef={dropRef}
|
|
|
isOver={isOver}
|
|
|
+ shouldShowVisualSelection={shouldShowVisualSelection}
|
|
|
>
|
|
|
<li className="bottom-buffer" />
|
|
|
</FileTreeFolderList>
|
|
|
@@ -82,6 +101,10 @@ function FileTreeRootFolder() {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+FileTreeRootFolder.propTypes = {
|
|
|
+ shouldShowVisualSelection: PropTypes.bool,
|
|
|
+}
|
|
|
+
|
|
|
FileTreeRoot.propTypes = {
|
|
|
onSelect: PropTypes.func.isRequired,
|
|
|
onInit: PropTypes.func.isRequired,
|