diff --git a/packages/material-ui/src/MenuList/MenuList.js b/packages/material-ui/src/MenuList/MenuList.js index 5ce5ba555b78cd..2679039ee335b6 100644 --- a/packages/material-ui/src/MenuList/MenuList.js +++ b/packages/material-ui/src/MenuList/MenuList.js @@ -61,7 +61,7 @@ function moveFocus( // Prevent infinite loop. if (nextFocus === list.firstChild) { if (wrappedOnce) { - return; + return false; } wrappedOnce = true; } @@ -80,9 +80,10 @@ function moveFocus( nextFocus = traversalFunction(list, nextFocus, disableListWrap); } else { nextFocus.focus(); - return; + return true; } } + return false; } const useEnhancedEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect; diff --git a/packages/material-ui/test/integration/MenuList.test.js b/packages/material-ui/test/integration/MenuList.test.js index 08560b8fab1a8d..56f9cd9152b5d0 100644 --- a/packages/material-ui/test/integration/MenuList.test.js +++ b/packages/material-ui/test/integration/MenuList.test.js @@ -519,13 +519,14 @@ describe(' integration', () => { it('matches rapidly typed text', () => { render( + War Worm Ordinary , ); fireEvent.keyDown(screen.getByRole('menu'), { key: 'W' }); - fireEvent.keyDown(screen.getByText('Worm'), { key: 'o' }); + fireEvent.keyDown(screen.getByText('War'), { key: 'o' }); expect(screen.getByText('Worm')).toHaveFocus(); });