Skip to content

Commit

Permalink
fix(useActiveElement): use useLayoutMount to prevent layout jitter
Browse files Browse the repository at this point in the history
  • Loading branch information
vikiboss committed Jul 10, 2024
1 parent 4a946b6 commit f8e2597
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/use-active-element/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEventListener } from '../use-event-listener'
import { useMount } from '../use-mount'
import { useLayoutMount } from '../use-layout-mount'
import { useSafeState } from '../use-safe-state'

export interface UseActiveElementOptions {
Expand Down Expand Up @@ -30,7 +30,7 @@ export function useActiveElement(options: UseActiveElementOptions = {}): Element
}
}

useMount(updateElement)
useLayoutMount(updateElement)

useEventListener(() => window, 'focus', updateElement, true)
useEventListener(() => window, 'blur', blurHandler, true)
Expand Down

0 comments on commit f8e2597

Please sign in to comment.