From 8b642ea292a2f1991393599ce65abd2bc9a51602 Mon Sep 17 00:00:00 2001 From: Alexander Schoenenwald Date: Tue, 15 Aug 2023 17:18:37 +0200 Subject: [PATCH] Fix right click to show request actions (#6275) --- .../insomnia/src/ui/components/base/dropdown/dropdown.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/insomnia/src/ui/components/base/dropdown/dropdown.tsx b/packages/insomnia/src/ui/components/base/dropdown/dropdown.tsx index 266b83055..62b03bccb 100644 --- a/packages/insomnia/src/ui/components/base/dropdown/dropdown.tsx +++ b/packages/insomnia/src/ui/components/base/dropdown/dropdown.tsx @@ -2,7 +2,7 @@ import { PressResponder } from '@react-aria/interactions'; import type { AriaMenuProps, MenuTriggerProps } from '@react-types/menu'; import type { Placement } from '@react-types/overlays'; import classnames from 'classnames'; -import React, { CSSProperties, forwardRef, ReactNode, useRef } from 'react'; +import React, { CSSProperties, forwardRef, ReactNode, useImperativeHandle, useRef } from 'react'; import { mergeProps, useMenuTrigger } from 'react-aria'; import { MenuTriggerState, useMenuTriggerState } from 'react-stately'; import styled from 'styled-components'; @@ -53,6 +53,12 @@ export const Dropdown = forwardRef((props: Dropdo onOpenChange: isOpen => isOpen ? onOpen?.() : onClose?.(), }); + useImperativeHandle(ref, () => ({ + show: () => state.open(), + hide: () => state.close(), + toggle: () => state.toggle(), + })); + const triggerRef = useRef(ref); const { menuTriggerProps, menuProps } = useMenuTrigger({ isDisabled }, state, triggerRef);