Skip to content

Commit

Permalink
fix: handle updates of align and position props when using auto-f…
Browse files Browse the repository at this point in the history
…lipping (#289)
  • Loading branch information
vishpatel7 authored May 11, 2021
1 parent 3036631 commit e7b491d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/hooks/useAutoFlip.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import invariant from 'invariant'
import { useCallback, useState } from 'react'
import { useCallback, useState, useEffect } from 'react'

import { positions } from '../defaultPosition'
import {
Expand Down Expand Up @@ -34,6 +34,11 @@ const useAutoFlip = (
initialAlign || getDefaultAlign(initialPosition)
)

useEffect(() => {
setCurrentPosition(initialPosition);
setCurrentAlign(initialAlign || getDefaultAlign(initialPosition));
}, [initialAlign, initialPosition]);

const checkAlignment = useCallback(
(nodeRef, anchorRef) => {
const [horizontalPosition, horizontalAlign] = autoFlipHorizontally(
Expand Down

1 comment on commit e7b491d

@vercel
Copy link

@vercel vercel bot commented on e7b491d May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.