diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/NavigationPanel.hooks.ts b/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/NavigationPanel.hooks.ts index 4b2f9bde2d..1b7a28c655 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/NavigationPanel.hooks.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/NavigationPanel.hooks.ts @@ -1,14 +1,16 @@ -import { useAppSelector } from '../../../stores/store'; +import { useAppDispatch, useAppSelector } from '../../../stores/store'; import { useNavigate } from 'react-router-dom'; import { IPage } from '../../../stores/reducers/pages/slice'; import { ViewLayoutTypePB } from '../../../../services/backend'; import { MouseEventHandler, useState } from 'react'; +import { activePageIdActions } from '../../../stores/reducers/activePageId/slice'; // number of pixels from left side of screen to show hidden navigation panel const FLOATING_PANEL_SHOW_WIDTH = 10; const FLOATING_PANEL_HIDE_EXTRA_WIDTH = 10; export const useNavigationPanelHooks = function () { + const dispatch = useAppDispatch(); const folders = useAppSelector((state) => state.folders); const pages = useAppSelector((state) => state.pages); const width = useAppSelector((state) => state.navigationWidth); @@ -52,6 +54,8 @@ export const useNavigationPanelHooks = function () { } })(); + dispatch(activePageIdActions.setActivePageId(page.id)); + navigate(`/page/${pageTypeRoute}/${page.id}`); }; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/PageItem.hooks.ts b/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/PageItem.hooks.ts index 77e53086be..9e608071e1 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/PageItem.hooks.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/PageItem.hooks.ts @@ -1,5 +1,5 @@ import { IPage, pagesActions } from '../../../stores/reducers/pages/slice'; -import { useAppDispatch } from '../../../stores/store'; +import { useAppDispatch, useAppSelector } from '../../../stores/store'; import { useState } from 'react'; import { nanoid } from 'nanoid'; import { ViewBackendService } from '../../../stores/effects/folder/view/view_bd_svc'; @@ -9,6 +9,7 @@ export const usePageEvents = (page: IPage) => { const appDispatch = useAppDispatch(); const [showPageOptions, setShowPageOptions] = useState(false); const [showRenamePopup, setShowRenamePopup] = useState(false); + const activePageId = useAppSelector((state) => state.activePageId); const viewBackendService: ViewBackendService = new ViewBackendService(page.id); const error = useError(); @@ -69,5 +70,6 @@ export const usePageEvents = (page: IPage) => { duplicatePage, closePopup, closeRenamePopup, + activePageId, }; }; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/PageItem.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/PageItem.tsx index 7b1186f95d..0d0affe33f 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/PageItem.tsx +++ b/frontend/appflowy_tauri/src/appflowy_app/components/layout/NavigationPanel/PageItem.tsx @@ -20,13 +20,16 @@ export const PageItem = ({ page, onPageClick }: { page: IPage; onPageClick: () = duplicatePage, closePopup, closeRenamePopup, + activePageId, } = usePageEvents(page); return (