Skip to content

Commit

Permalink
fix incorrect typing
Browse files Browse the repository at this point in the history
  • Loading branch information
rshen91 committed Oct 14, 2021
1 parent 540eaf6 commit c50b9e4
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import React, { useRef, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiContextMenuPanelDescriptor, EuiIcon, EuiPopover, EuiContextMenu } from '@elastic/eui';
import {
EuiContextMenuPanelDescriptor,
EuiIcon,
EuiPopover,
EuiContextMenu,
EuiButton,
} from '@elastic/eui';
import type { LensFilterEvent } from '../types';

export interface LegendActionPopoverProps {
Expand All @@ -31,7 +37,7 @@ export const LegendActionPopover: React.FunctionComponent<LegendActionPopoverPro
context,
}) => {
const [popoverOpen, setPopoverOpen] = useState(false);
const containerRef = useRef(null);
const containerRef = useRef<HTMLButtonElement | null>(null);
const panels: EuiContextMenuPanelDescriptor[] = [
{
id: 'main',
Expand Down Expand Up @@ -64,9 +70,8 @@ export const LegendActionPopover: React.FunctionComponent<LegendActionPopoverPro
];

const Button = (
<div
tabIndex={0}
ref={containerRef}
<EuiButton
buttonRef={containerRef}
role="button"
aria-pressed="false"
style={{
Expand All @@ -82,7 +87,7 @@ export const LegendActionPopover: React.FunctionComponent<LegendActionPopoverPro
onClick={() => setPopoverOpen(!popoverOpen)}
>
<EuiIcon size="s" type="boxesVertical" />
</div>
</EuiButton>
);
return (
<EuiPopover
Expand All @@ -91,7 +96,9 @@ export const LegendActionPopover: React.FunctionComponent<LegendActionPopoverPro
isOpen={popoverOpen}
closePopover={() => {
setPopoverOpen(false);
requestAnimationFrame(() => containerRef.current.focus());
if (containerRef.current) {
requestAnimationFrame(() => containerRef?.current?.focus?.());
}
}}
panelPaddingSize="none"
anchorPosition="upLeft"
Expand Down

0 comments on commit c50b9e4

Please sign in to comment.