Skip to content

Commit

Permalink
Modal/FocusTrap: useLayoutEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvuerings committed Mar 25, 2024
1 parent 3715437 commit 2f5fe85
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/syntax-core/src/Modal/FocusTrap.tsx
@@ -1,4 +1,4 @@
import React, { useEffect, useRef, type ReactElement } from "react";
import React, { useRef, type ReactElement, useLayoutEffect } from "react";

function queryFocusableAll(el: HTMLDivElement): NodeListOf<HTMLElement> {
// Focusable, interactive elements that could possibly be in children
Expand Down Expand Up @@ -39,7 +39,7 @@ export default function FocusTrap({
const elRef = useRef<HTMLDivElement | null>(null);
const previouslyFocusedElRef = useRef<HTMLElement | null>(null);

useEffect(() => {
useLayoutEffect(() => {
const { current: element } = elRef;

// Focus the first child element among all the focusable, interactive elements within `children`
Expand Down

0 comments on commit 2f5fe85

Please sign in to comment.