Skip to content

Commit

Permalink
simplify the conditionals to turn off autorfocus
Browse files Browse the repository at this point in the history
  • Loading branch information
linh-transcend committed Dec 6, 2024
1 parent ac4a659 commit 570d7e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function Main({
const dialogRef = useRef<HTMLDivElement>(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) {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 570d7e9

Please sign in to comment.