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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user