Merge pull request #6778 from overleaf/ta-revert-file-tree-selection-flat

Revert File Tree File Selection in Flat PDF View

GitOrigin-RevId: c82b0155c4e028ee54345083c97c4ee3b7cc7ed5
This commit is contained in:
Timothée Alby 2022-02-15 17:29:32 +01:00 committed by Copybot
parent 2d9ceeba49
commit 4dc4286d1b

View file

@ -15,7 +15,6 @@ import { findInTree } from '../util/find-in-tree'
import { useFileTreeData } from '../../../shared/context/file-tree-data-context'
import { useProjectContext } from '../../../shared/context/project-context'
import { useEditorContext } from '../../../shared/context/editor-context'
import { useLayoutContext } from '../../../shared/context/layout-context'
import usePersistedState from '../../../shared/hooks/use-persisted-state'
import usePreviousValue from '../../../shared/hooks/use-previous-value'
@ -194,9 +193,7 @@ const projectContextPropTypes = {
const editorContextPropTypes = {
permissionsLevel: PropTypes.oneOf(['readOnly', 'readAndWrite', 'owner']),
}
export function useSelectableEntity(id) {
const { view, setView } = useLayoutContext(layoutContextPropTypes)
const { selectedEntityIds, selectOrMultiSelectEntity } = useContext(
FileTreeSelectableContext
)
@ -206,9 +203,8 @@ export function useSelectableEntity(id) {
const handleEvent = useCallback(
ev => {
selectOrMultiSelectEntity(id, ev.ctrlKey || ev.metaKey)
setView('editor')
},
[id, selectOrMultiSelectEntity, setView]
[id, selectOrMultiSelectEntity]
)
const handleClick = useCallback(
@ -237,26 +233,20 @@ export function useSelectableEntity(id) {
[id, handleEvent, selectedEntityIds]
)
const isVisuallySelected = isSelected && view !== 'pdf'
const props = useMemo(
() => ({
className: classNames({ selected: isVisuallySelected }),
'aria-selected': isVisuallySelected,
className: classNames({ selected: isSelected }),
'aria-selected': isSelected,
onClick: handleClick,
onContextMenu: handleContextMenu,
onKeyPress: handleKeyPress,
}),
[handleClick, handleContextMenu, handleKeyPress, isVisuallySelected]
[handleClick, handleContextMenu, handleKeyPress, isSelected]
)
return { isSelected, props }
}
const layoutContextPropTypes = {
view: PropTypes.string,
setView: PropTypes.func.isRequired,
}
export function useFileTreeSelectable() {
const context = useContext(FileTreeSelectableContext)