Skip to content

Commit 69f68bd

Browse files
iampranavsethidaniloff200
authored andcommitted
fix(popover): add fallback value if parseFloat on css fails
Arrow positioning for certain corner placements on popover fails on firefox (possibly other non-webkit browsers). In this case, parseFloat() returns NaN and resulting in all operations to be converted to NaN. Adding fallback to 0 in case the parseFloat returns NaN
1 parent a929485 commit 69f68bd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/positioning/modifiers/arrow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ export function arrow(data: Data) {
3636
// Compute the sideValue using the updated target offsets
3737
// take target margin in account because we don't have this info available
3838
const css = getStyleComputedProperty(data.instance.target) as unknown as Record<string, string>;
39-
const targetMarginSide = parseFloat(css[`margin${sideCapitalized}`]);
40-
const targetBorderSide = parseFloat(css[`border${sideCapitalized}Width`]);
39+
const targetMarginSide = parseFloat(css[`margin${sideCapitalized}`]) || 0;
40+
const targetBorderSide = parseFloat(css[`border${sideCapitalized}Width`]) || 0;
4141

4242
// compute center of the target
4343
let center: number;
4444
if (!placementVariation) {
4545
center = Number((data).offsets.host[side]) + Number(data.offsets.host[len] / 2 - arrowElementSize / 2);
4646
} else {
47-
const targetBorderRadius = parseFloat(css.borderRadius);
47+
const targetBorderRadius = parseFloat(css.borderRadius) || 0;
4848
const targetSideArrowOffset = Number(targetMarginSide + targetBorderSide + targetBorderRadius);
4949
center = side === placementVariation ?
5050
Number((data).offsets.host[side]) + targetSideArrowOffset :

0 commit comments

Comments
 (0)