about summary refs log tree commit diff
path: root/src/components/ContextMenu/context.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/ContextMenu/context.tsx')
-rw-r--r--src/components/ContextMenu/context.tsx20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/components/ContextMenu/context.tsx b/src/components/ContextMenu/context.tsx
index 213d87a8c..cecb6a18d 100644
--- a/src/components/ContextMenu/context.tsx
+++ b/src/components/ContextMenu/context.tsx
@@ -1,9 +1,15 @@
 import React from 'react'
 
-import type {ContextType, ItemContextType} from '#/components/ContextMenu/types'
+import {
+  type ContextType,
+  type ItemContextType,
+  type MenuContextType,
+} from '#/components/ContextMenu/types'
 
 export const Context = React.createContext<ContextType | null>(null)
 
+export const MenuContext = React.createContext<MenuContextType | null>(null)
+
 export const ItemContext = React.createContext<ItemContextType | null>(null)
 
 export function useContextMenuContext() {
@@ -18,6 +24,18 @@ export function useContextMenuContext() {
   return context
 }
 
+export function useContextMenuMenuContext() {
+  const context = React.useContext(MenuContext)
+
+  if (!context) {
+    throw new Error(
+      'useContextMenuMenuContext must be used within a Context.Provider',
+    )
+  }
+
+  return context
+}
+
 export function useContextMenuItemContext() {
   const context = React.useContext(ItemContext)