Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit e7da7fc

Browse files
maxjacobsonFezVrasta
authored andcommitted
fix: update TypeScript types to allow SVG references (#299)
fixes #277 Flow is not updated because it doesn't support SVG types
1 parent 400eceb commit e7da7fc

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

typings/react-popper.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface ManagerProps {
66
}
77
export class Manager extends React.Component<ManagerProps, {}> { }
88

9-
type RefHandler = (ref: HTMLElement | null) => void;
9+
type RefHandler = (ref: HTMLElement | SVGElement | null) => void;
1010

1111
interface ReferenceChildrenProps {
1212
ref: RefHandler;

typings/tests/svg-test.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Please remember to update also the Flow test files that can
2+
// be found under `/src/__typings__` please. Thanks! 🤗
3+
4+
import * as React from 'react';
5+
import { Manager, Reference, Popper } from '../..';
6+
7+
export const Test = () => (
8+
<Manager>
9+
<svg>
10+
<Reference>{({ ref }) => <g ref={ref} />}</Reference>
11+
</svg>
12+
<Popper
13+
eventsEnabled
14+
positionFixed
15+
modifiers={{ flip: { enabled: false } }}
16+
>
17+
{({
18+
ref,
19+
style,
20+
placement,
21+
outOfBoundaries,
22+
scheduleUpdate,
23+
arrowProps,
24+
}) => (
25+
<div
26+
ref={ref}
27+
style={{ ...style, opacity: outOfBoundaries ? 0 : 1 }}
28+
data-placement={placement}
29+
onClick={() => scheduleUpdate()}
30+
>
31+
Popper
32+
<div ref={arrowProps.ref} style={arrowProps.style} />
33+
</div>
34+
)}
35+
</Popper>
36+
<Popper>
37+
{({ ref, style, placement }) => (
38+
<div ref={ref} style={style} data-placement={placement}>
39+
Popper
40+
</div>
41+
)}
42+
</Popper>
43+
</Manager>
44+
);

0 commit comments

Comments
 (0)