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);