From 846ccd3aaca0c5d5cfcbbf90f4e6dddda0825915 Mon Sep 17 00:00:00 2001 From: David <33458145+davidmcpowell@users.noreply.github.com> Date: Tue, 15 Apr 2025 09:13:10 +0100 Subject: [PATCH] Merge pull request #24859 from overleaf/dp-history-file-tree Always show file tree in history view in new editor GitOrigin-RevId: e993aae4c1625ef7fb0a716ae5bff8edb0e8d0d0 --- .../ide-react/context/react-context-root.tsx | 44 +++++++++---------- .../js/shared/context/layout-context.tsx | 22 +++++++++- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/services/web/frontend/js/features/ide-react/context/react-context-root.tsx b/services/web/frontend/js/features/ide-react/context/react-context-root.tsx index 72c25b88c9..2b94145d20 100644 --- a/services/web/frontend/js/features/ide-react/context/react-context-root.tsx +++ b/services/web/frontend/js/features/ide-react/context/react-context-root.tsx @@ -77,33 +77,33 @@ export const ReactContextRoot: FC<{ providers?: Record }> = ({ - - - - - - - - - - - + + + + + + + + + + + {children} - - - - - - - - - - - + + + + + + + + + + + diff --git a/services/web/frontend/js/shared/context/layout-context.tsx b/services/web/frontend/js/shared/context/layout-context.tsx index 145d840540..d3b1344cfe 100644 --- a/services/web/frontend/js/shared/context/layout-context.tsx +++ b/services/web/frontend/js/shared/context/layout-context.tsx @@ -21,6 +21,7 @@ import useEventListener from '@/shared/hooks/use-event-listener' import { isSplitTestEnabled } from '@/utils/splitTestUtils' import { isMac } from '@/shared/utils/os' import { sendSearchEvent } from '@/features/event-tracking/search-events' +import { useRailContext } from '@/features/ide-redesign/contexts/rail-context' export type IdeLayout = 'sideBySide' | 'flat' export type IdeView = 'editor' | 'file' | 'pdf' | 'history' @@ -75,6 +76,8 @@ export const LayoutProvider: FC = ({ children }) => { const [view, _setView] = useScopeValue('ui.view') const [openFile] = useScopeValue('openFile') const historyToggleEmitter = useScopeEventEmitter('history:toggle', true) + const { isOpen: railIsOpen, setIsOpen: setRailIsOpen } = useRailContext() + const [prevRailIsOpen, setPrevRailIsOpen] = useState(railIsOpen) const setView = useCallback( (value: IdeView | null) => { @@ -84,6 +87,15 @@ export const LayoutProvider: FC = ({ children }) => { historyToggleEmitter() } + if (value === 'history') { + setPrevRailIsOpen(railIsOpen) + setRailIsOpen(true) + } + + if (oldValue === 'history') { + setRailIsOpen(prevRailIsOpen) + } + if (value === 'editor' && openFile) { // if a file is currently opened, ensure the view is 'file' instead of // 'editor' when the 'editor' view is requested. This is to ensure @@ -95,7 +107,15 @@ export const LayoutProvider: FC = ({ children }) => { return value }) }, - [_setView, openFile, historyToggleEmitter] + [ + _setView, + setRailIsOpen, + openFile, + historyToggleEmitter, + prevRailIsOpen, + setPrevRailIsOpen, + railIsOpen, + ] ) // whether the chat pane is open