diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-03-27 18:53:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-27 09:53:42 -0700 |
commit | 7d1ebf6a027085ddc10a7dad2075d5e52d314233 (patch) | |
tree | 7a76364ad0684aa78cb8b267dd039518e2830fd7 /src/components/ContextMenu/context.tsx | |
parent | 1e688dee248dcbee318ed241bc19968b711bc546 (diff) | |
download | voidsky-7d1ebf6a027085ddc10a7dad2075d5e52d314233.tar.zst |
Allow selecting `ContextMenu` options via press-and-hold (#8020)
* save locations of menu items * enable panning to select items * rm unused type * fix haptic overfiring
Diffstat (limited to 'src/components/ContextMenu/context.tsx')
-rw-r--r-- | src/components/ContextMenu/context.tsx | 20 |
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) |