diff --git a/src/components/Main.tsx b/src/components/Main.tsx index 36075af..a3fd7cb 100644 --- a/src/components/Main.tsx +++ b/src/components/Main.tsx @@ -77,7 +77,7 @@ export function Main({ const dialogRef = useRef(null); useEffect(() => { if (!isViewStateClosed(viewState) && dialogRef.current) { - const shouldAutofocus = !config?.autofocus || config?.autofocus === 'on'; + const shouldAutofocus = config?.autofocus !== 'off'; // This setTimeout was necessary for the api triggered states, (DoNotSell|OptOut)Disclosure setTimeout(() => { if (dialogRef.current && shouldAutofocus) { diff --git a/src/hooks/useViewState.ts b/src/hooks/useViewState.ts index ab7eba3..12baf83 100644 --- a/src/hooks/useViewState.ts +++ b/src/hooks/useViewState.ts @@ -137,7 +137,7 @@ export function useViewState({ * very difficult to interact with. We create an element with maximum focus priority and * focus it so that when we delete it the user will be at the start of the focus order * just like if they had freshly loaded the page. */ - const shouldFocus = !autofocus || autofocus === 'on'; + const shouldFocus = autofocus !== 'off'; if (savedActiveElement !== null && shouldFocus) { savedActiveElement.focus(); } else {