diff --git a/packages/main/src/components/MessageBox/index.tsx b/packages/main/src/components/MessageBox/index.tsx index 3fe6047f3bc..3dc4e87d356 100644 --- a/packages/main/src/components/MessageBox/index.tsx +++ b/packages/main/src/components/MessageBox/index.tsx @@ -200,9 +200,9 @@ const MessageBox = forwardRef((props, ref) => const internalActions = getActions(actions, type); const getInitialFocus = () => { - const actionToFocus = internalActions.find((action) => action === initialFocus); - if (typeof actionToFocus === 'string') { - return `${messageBoxId}-action-${actionToFocus}`; + const index = internalActions.findIndex((action) => action === initialFocus); + if (index !== -1 && typeof internalActions[index] === 'string') { + return `${messageBoxId}-action-${index}`; } return initialFocus; }; @@ -253,7 +253,7 @@ const MessageBox = forwardRef((props, ref) => if (typeof action === 'string') { return (