Skip to content

Commit

Permalink
Merge pull request #2569 from gluestack/fix/popover-arrow-style-issue
Browse files Browse the repository at this point in the history
fix: popover arrow style issue
  • Loading branch information
Viraj-10 authored Nov 7, 2024
2 parents 85093f7 + 7dfaa95 commit b12be5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 0 additions & 2 deletions packages/unstyled/popover/src/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { forwardRef } from 'react';
import { useControllableState } from '@gluestack-ui/hooks';
import { Overlay } from '@gluestack-ui/overlay';

// import { useOverlayPosition } from '@react-native-aria/overlays';
import { PopoverProvider } from './PopoverContext';

export const Popover = (StyledPopover: any) =>
Expand Down
27 changes: 17 additions & 10 deletions packages/unstyled/popover/src/PopoverArrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ const PopoverArrow = (StyledPopoverArrow: any) =>
});
}, [arrowHeight, arrowWidth, placement, actualPlacement]);

if (arrowProps?.style?.left) {
arrowProps.style.left -= arrowWidth / 2;
} else if (arrowProps?.style?.top) {
arrowProps.style.top -= arrowHeight / 2;
}
const ArrowStyle = React.useMemo(() => {
return {
top: arrowProps?.style?.top - arrowHeight / 2,
left: arrowProps?.style?.left - arrowWidth / 2,
};
}, [
arrowHeight,
arrowWidth,
arrowProps?.style?.top,
arrowProps?.style?.left,
]);

React.useEffect(() => {
const ArrowComponent = (
Expand All @@ -42,6 +48,7 @@ const PopoverArrow = (StyledPopoverArrow: any) =>
updateArrowSize({ height, width });
}}
{...props}
{...ArrowStyle}
key={actualPlacement + 'arrow'}
initial={{
opacity: 0,
Expand Down Expand Up @@ -71,15 +78,15 @@ const PopoverArrow = (StyledPopoverArrow: any) =>
}}
style={[
props?.style,
arrowProps?.style,
ArrowStyle,
{
// To avoid border radius case
top:
placement === 'right bottom' || placement === 'left bottom'
? arrowProps?.style?.top > 4
? arrowProps?.style?.top - 4
: arrowProps?.style?.top
: arrowProps?.style?.top,
? ArrowStyle?.top > 4
? ArrowStyle?.top - 4
: ArrowStyle?.top
: ArrowStyle?.top,
},
additionalStyles,
]}
Expand Down

0 comments on commit b12be5a

Please sign in to comment.