Skip to content

Commit

Permalink
Fix main menu still open after page transition
Browse files Browse the repository at this point in the history
  • Loading branch information
0xi4o committed Aug 25, 2024
1 parent 48f0a40 commit 513ae76
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 59 deletions.
110 changes: 53 additions & 57 deletions app/components/editor/main-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const MainMenu = ({
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem
className='flex items-center justify-between'
className='w-full flex items-center justify-between'
onClick={() =>
triggerShortcut(
EditorShortcuts.NEW_POST
Expand All @@ -97,31 +97,32 @@ const MainMenu = ({
/>
</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>
<Link
className='flex items-center justify-between'
prefetch='intent'
to={ROUTES.VIEW.POSTS}
>
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<ListIcon className='mr-2 w-4 h-4' />
<span>View All Posts</span>
</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.VIEW_ALL_POSTS
].key,
allShortcuts[
EditorShortcuts
.VIEW_ALL_POSTS
].modifiers
)}
/>
</DropdownMenuShortcut>
</Link>
<DropdownMenuItem
className='w-full flex items-center justify-between'
onClick={() =>
triggerShortcut(
EditorShortcuts.VIEW_ALL_POSTS
)
}
>
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<ListIcon className='mr-2 w-4 h-4' />
<span>View All Posts</span>
</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.VIEW_ALL_POSTS
].key,
allShortcuts[
EditorShortcuts
.VIEW_ALL_POSTS
].modifiers
)}
/>
</DropdownMenuShortcut>
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuPortal>
Expand Down Expand Up @@ -162,37 +163,32 @@ const MainMenu = ({
/>
</DropdownMenuShortcut>
</DropdownMenuItem>
{/*<DropdownMenuItem>*/}
{/* <span className='w-full h-full flex items-center justify-start cursor-pointer'>*/}
{/* <RefreshCcwIcon className='mr-2 w-4 h-4' />*/}
{/* <span>Resume Previous Session</span>*/}
{/* </span>*/}
{/*</DropdownMenuItem>*/}
<DropdownMenuItem>
<Link
className='flex items-center justify-between'
prefetch='intent'
to={ROUTES.VIEW.WRITING_SESSIONS}
>
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<ListIcon className='mr-2 w-4 h-4' />
<span>View All Sessions</span>
</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].key,
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].modifiers
)}
/>
</DropdownMenuShortcut>
</Link>
<DropdownMenuItem
className='flex items-center justify-between'
onClick={() =>
triggerShortcut(
EditorShortcuts.VIEW_ALL_WRITING_SESSIONS
)
}
>
<span className='w-full h-full flex items-center justify-start cursor-pointer'>
<ListIcon className='mr-2 w-4 h-4' />
<span>View All Sessions</span>
</span>
<DropdownMenuShortcut className='ml-16'>
<KeyboardShortcut
keys={getShortcutWithModifiers(
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].key,
allShortcuts[
EditorShortcuts
.VIEW_ALL_WRITING_SESSIONS
].modifiers
)}
/>
</DropdownMenuShortcut>
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuPortal>
Expand Down
10 changes: 8 additions & 2 deletions app/lib/providers/aurelius.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,17 @@ const AureliusProvider = ({ children }: AureliusProviderProps) => {
}

const viewAllPosts = () => {
navigate(ROUTES.VIEW.POSTS)
setMainMenuOpen(() => false)
startTransition(() => {
navigate(ROUTES.VIEW.POSTS)
})
}

const viewAllWritingSessions = () => {
navigate(ROUTES.VIEW.WRITING_SESSIONS)
setMainMenuOpen(() => false)
startTransition(() => {
navigate(ROUTES.VIEW.WRITING_SESSIONS)
})
}

const data: AureliusProviderData = {
Expand Down

0 comments on commit 513ae76

Please sign in to comment.