Skip to content

Commit 8a1a35d

Browse files
committed
Make InteractivePopover take a type argument of the trigger HTMLElement
1 parent 5a6c445 commit 8a1a35d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/compass-components/src/components/interactive-popover.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ const closeButtonStyles = css({
4242
right: spacing[2],
4343
});
4444

45-
type InteractivePopoverProps = {
45+
type InteractivePopoverProps<TriggerElement extends HTMLElement> = {
4646
className?: string;
4747
children: React.ReactNode;
4848
trigger: (triggerProps: {
49-
onClick: React.MouseEventHandler<HTMLButtonElement>;
50-
ref: React.LegacyRef<HTMLButtonElement>;
49+
onClick: React.MouseEventHandler<TriggerElement>;
50+
ref: React.Ref<TriggerElement>;
5151
children: React.ReactNode;
5252
}) => React.ReactElement;
5353
hideCloseButton?: boolean;
@@ -65,7 +65,7 @@ type InteractivePopoverProps = {
6565
'align' | 'justify' | 'spacing' | 'popoverZIndex'
6666
>;
6767

68-
function InteractivePopover({
68+
function InteractivePopover<TriggerElement extends HTMLElement>({
6969
className,
7070
children,
7171
trigger,
@@ -80,9 +80,9 @@ function InteractivePopover({
8080
popoverZIndex,
8181
containerClassName,
8282
closeButtonClassName,
83-
}: InteractivePopoverProps): React.ReactElement {
83+
}: InteractivePopoverProps<TriggerElement>): React.ReactElement {
8484
const darkMode = useDarkMode();
85-
const triggerRef = useRef<HTMLButtonElement>(null);
85+
const triggerRef = useRef<TriggerElement>(null);
8686
const closeButtonRef = useRef<HTMLButtonElement>(null);
8787
const popoverContentContainerRef = useRef<HTMLDivElement>(null);
8888

0 commit comments

Comments
 (0)