Skip to content

Commit

Permalink
perf(AnchoredOverlay): memoize position object
Browse files Browse the repository at this point in the history
  • Loading branch information
dgreif committed Apr 30, 2021
1 parent 5c81b1e commit ed3aba1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/AnchoredOverlay/AnchoredOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export const AnchoredOverlay: React.FC<AnchoredOverlayProps> = ({renderAnchor, c
},
[overlayRef.current]
)
const overlayPosition = position && {top: `${position.top}px`, left: `${position.left}px`}
const overlayPosition = useMemo(() => {
return position && {top: `${position.top}px`, left: `${position.left}px`}
}, [position])

useFocusZone({containerRef: overlayRef, disabled: !open || focusType !== 'list' || !position})
useFocusTrap({containerRef: overlayRef, disabled: !open || focusType !== 'list' || !position})
Expand Down

0 comments on commit ed3aba1

Please sign in to comment.