mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 02:51:57 +02:00
Merge pull request #28290 from overleaf/mj-outline-hide-when-last-file-deleted
[web] Hide project outline when no file is selected GitOrigin-RevId: 0fa5b54c63e3b545f4382a48a40823f0dfea23a4
This commit is contained in:
committed by
Copybot
parent
ba1a4312a8
commit
af302b7c2f
@@ -15,6 +15,7 @@ import { isValidTeXFile } from '@/main/is-valid-tex-file'
|
||||
import localStorage from '@/infrastructure/local-storage'
|
||||
import { useProjectContext } from '@/shared/context/project-context'
|
||||
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
||||
import { useFileTreeOpenContext } from './file-tree-open-context'
|
||||
|
||||
export type PartialFlatOutline = {
|
||||
level: number
|
||||
@@ -126,6 +127,9 @@ export const OutlineProvider: FC<React.PropsWithChildren> = ({ children }) => {
|
||||
[openDocName]
|
||||
)
|
||||
|
||||
const { selectedEntityCount } = useFileTreeOpenContext()
|
||||
const hasSingleEntityOpen = selectedEntityCount === 1
|
||||
|
||||
const { projectId } = useProjectContext()
|
||||
const storageKey = `file_outline.expanded.${projectId}`
|
||||
|
||||
@@ -133,7 +137,7 @@ export const OutlineProvider: FC<React.PropsWithChildren> = ({ children }) => {
|
||||
() => localStorage.getItem(storageKey) !== false
|
||||
)
|
||||
|
||||
const canShowOutline = isTexFile && !binaryFileOpened
|
||||
const canShowOutline = hasSingleEntityOpen && isTexFile && !binaryFileOpened
|
||||
|
||||
const expandOutline = useCallback(() => {
|
||||
if (canShowOutline) {
|
||||
|
||||
Reference in New Issue
Block a user