diff --git a/apps/core/src/components/pure/workspace-slider-bar/components/reference-page.tsx b/apps/core/src/components/pure/workspace-slider-bar/components/reference-page.tsx
index 46cc2a30bc..a92763347a 100644
--- a/apps/core/src/components/pure/workspace-slider-bar/components/reference-page.tsx
+++ b/apps/core/src/components/pure/workspace-slider-bar/components/reference-page.tsx
@@ -52,7 +52,7 @@ export const ReferencePage = ({
data-type="favorite-list-item"
data-testid={`favorite-list-item-${pageId}`}
active={active}
- href={`/workspace/${workspace.id}/${pageId}`}
+ to={`/workspace/${workspace.id}/${pageId}`}
icon={icon}
collapsed={collapsible ? collapsed : undefined}
onCollapsedChange={setCollapsed}
diff --git a/apps/core/src/components/root-app-sidebar/index.tsx b/apps/core/src/components/root-app-sidebar/index.tsx
index ba6e3270b1..a19c2dd17a 100644
--- a/apps/core/src/components/root-app-sidebar/index.tsx
+++ b/apps/core/src/components/root-app-sidebar/index.tsx
@@ -53,7 +53,7 @@ const RouteMenuLinkItem = React.forwardRef<
HTMLDivElement,
{
currentPath: string; // todo: pass through useRouter?
- path?: string | null;
+ path: string;
icon: ReactElement;
children?: ReactElement;
isDraggedOver?: boolean;
@@ -66,7 +66,7 @@ const RouteMenuLinkItem = React.forwardRef<
ref={ref}
{...props}
active={active}
- href={path ?? ''}
+ to={path ?? ''}
icon={icon}
>
{children}
@@ -169,7 +169,7 @@ export const RootAppSidebar = ({
}
currentPath={currentPath}
- path={currentWorkspaceId && paths.all(currentWorkspaceId)}
+ path={paths.all(currentWorkspaceId)}
onClick={backToAll}
>
{t['All pages']()}
@@ -198,7 +198,7 @@ export const RootAppSidebar = ({
isDraggedOver={trashDroppable.isOver}
icon={}
currentPath={currentPath}
- path={currentWorkspaceId && paths.trash(currentWorkspaceId)}
+ path={paths.trash(currentWorkspaceId)}
>
{t['Trash']()}
diff --git a/apps/storybook/src/stories/app-sidebar.stories.tsx b/apps/storybook/src/stories/app-sidebar.stories.tsx
index 55a2761933..5b6e6717cc 100644
--- a/apps/storybook/src/stories/app-sidebar.stories.tsx
+++ b/apps/storybook/src/stories/app-sidebar.stories.tsx
@@ -24,6 +24,7 @@ import {
import type { Meta, StoryFn } from '@storybook/react';
import { useAtom } from 'jotai';
import { type PropsWithChildren, useState } from 'react';
+import { MemoryRouter } from 'react-router-dom';
export default {
title: 'Components/AppSidebar',
@@ -31,18 +32,20 @@ export default {
} satisfies Meta;
const Container = ({ children }: PropsWithChildren) => (
-
- {children}
-
+
+
+ {children}
+
+
);
const Main = () => {
const [open, setOpen] = useAtom(appSidebarOpenAtom);
@@ -94,21 +97,21 @@ export const WithItems: StoryFn = () => {
}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Settings
}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Settings
}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Settings
@@ -121,7 +124,7 @@ export const WithItems: StoryFn = () => {
collapsed={collapsed}
onCollapsedChange={setCollapsed}
icon={}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Collapsible Item
@@ -130,14 +133,14 @@ export const WithItems: StoryFn = () => {
collapsed={!collapsed}
onCollapsedChange={setCollapsed}
icon={}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Collapsible Item
}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Settings
@@ -146,7 +149,7 @@ export const WithItems: StoryFn = () => {
}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Trash
diff --git a/packages/component/src/components/app-sidebar/menu-item/index.stories.tsx b/packages/component/src/components/app-sidebar/menu-item/index.stories.tsx
index e67b65a961..542819a72e 100644
--- a/packages/component/src/components/app-sidebar/menu-item/index.stories.tsx
+++ b/packages/component/src/components/app-sidebar/menu-item/index.stories.tsx
@@ -18,7 +18,7 @@ export const Default: StoryFn = () => {
}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Normal Link Item
@@ -26,7 +26,7 @@ export const Default: StoryFn = () => {
}
- href="/test"
+ to="/test"
onClick={() => alert('opened')}
>
Primary Item
diff --git a/packages/component/src/components/app-sidebar/menu-item/index.tsx b/packages/component/src/components/app-sidebar/menu-item/index.tsx
index 3575849369..0abf0ea4f5 100644
--- a/packages/component/src/components/app-sidebar/menu-item/index.tsx
+++ b/packages/component/src/components/app-sidebar/menu-item/index.tsx
@@ -1,7 +1,8 @@
import { ArrowDownSmallIcon } from '@blocksuite/icons';
-import { Link, type LinkProps } from '@mui/material';
import clsx from 'clsx';
import React from 'react';
+import type { LinkProps } from 'react-router-dom';
+import { Link } from 'react-router-dom';
import * as styles from './index.css';
@@ -16,7 +17,7 @@ export interface MenuItemProps extends React.HTMLAttributes {
export interface MenuLinkItemProps
extends MenuItemProps,
- Pick {}
+ Pick {}
const stopPropagation: React.MouseEventHandler = e => {
e.stopPropagation();
@@ -90,9 +91,9 @@ export const MenuItem = React.forwardRef(
MenuItem.displayName = 'MenuItem';
export const MenuLinkItem = React.forwardRef(
- ({ href, ...props }, ref) => {
+ ({ to, ...props }, ref) => {
return (
-
+
{/* The element rendered by Link does not generate display box due to `display: contents` style */}
{/* Thus ref is passed to MenuItem instead of Link */}