Skip to content

Commit 54bbb8f

Browse files
authored
fix(react-native): arrows (floating-ui#1685)
1 parent 94324c7 commit 54bbb8f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/core/src/middleware/arrow.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ export const arrow = (options: Options): Middleware => ({
5656
const startDiff = coords[axis] - rects.reference[axis];
5757

5858
const arrowOffsetParent = await platform.getOffsetParent?.(element);
59-
const clientSize = arrowOffsetParent
59+
let clientSize = arrowOffsetParent
6060
? axis === 'y'
6161
? arrowOffsetParent.clientHeight || 0
6262
: arrowOffsetParent.clientWidth || 0
6363
: 0;
6464

65+
if (clientSize === 0) {
66+
clientSize = rects.floating[length];
67+
}
68+
6569
const centerToReference = endDiff / 2 - startDiff / 2;
6670

6771
// Make sure the arrow doesn't overflow the floating element if the center

packages/react-native/src/createPlatform.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Dimensions} from 'react-native';
2-
import {Platform, Dimensions as DimensionsType} from '@floating-ui/core';
2+
import {Platform} from '@floating-ui/core';
33

44
const ORIGIN = {x: 0, y: 0};
55

@@ -67,9 +67,9 @@ export const createPlatform = ({
6767
}
6868
});
6969
},
70-
getDimensions: ({element}) =>
70+
getDimensions: (element) =>
7171
new Promise((resolve) =>
72-
element.measure(({width, height}: DimensionsType) =>
72+
element.measure((x: number, y: number, width: number, height: number) =>
7373
resolve({width, height})
7474
)
7575
),

0 commit comments

Comments
 (0)