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:
Samuel Newman
2025-03-27 18:53:42 +02:00
committed by GitHub
parent 1e688dee24
commit 7d1ebf6a02
3 changed files with 330 additions and 101 deletions
+19 -1
View File
@@ -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)