Fix right click to show request actions (#6275)

This commit is contained in:
Alexander Schoenenwald 2023-08-15 17:18:37 +02:00 committed by GitHub
parent 9f6e2f3485
commit 8b642ea292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<DropdownHandle, DropdownProps>((props: Dropdo
onOpenChange: isOpen => isOpen ? onOpen?.() : onClose?.(),
});
useImperativeHandle(ref, () => ({
show: () => state.open(),
hide: () => state.close(),
toggle: () => state.toggle(),
}));
const triggerRef = useRef<HTMLButtonElement>(ref);
const { menuTriggerProps, menuProps } = useMenuTrigger({ isDisabled }, state, triggerRef);