diff --git a/packages/vkui/src/components/FocusTrap/FocusTrap.test.tsx b/packages/vkui/src/components/FocusTrap/FocusTrap.test.tsx index 0a54e577e1..248b3b023e 100644 --- a/packages/vkui/src/components/FocusTrap/FocusTrap.test.tsx +++ b/packages/vkui/src/components/FocusTrap/FocusTrap.test.tsx @@ -1,5 +1,4 @@ -import * as React from 'react'; -import { act } from 'react'; +import { act, Fragment, useRef, useState } from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import { ViewWidth } from '../../lib/adaptivity'; import { @@ -12,6 +11,8 @@ import { ActionSheet, ActionSheetProps } from '../ActionSheet/ActionSheet'; import { ActionSheetItem } from '../ActionSheetItem/ActionSheetItem'; import { AdaptivityProvider } from '../AdaptivityProvider/AdaptivityProvider'; import { AppRoot } from '../AppRoot/AppRoot'; +import { AppRootContext, DEFAULT_APP_ROOT_CONTEXT_VALUE } from '../AppRoot/AppRootContext'; +import { Button } from '../Button/Button'; import { CellButton } from '../CellButton/CellButton'; import { Panel } from '../Panel/Panel'; import { SplitCol } from '../SplitCol/SplitCol'; @@ -30,8 +31,8 @@ const ActionSheetTest = ({ onClose: onCloseProp, ...props }: Partial & Partial) => { - const toggleRef = React.useRef(null); - const [actionSheet, toggleActionSheet] = React.useState(null); + const toggleRef = useRef(null); + const [actionSheet, toggleActionSheet] = useState(null); const handleClose = () => { if (onCloseProp) { @@ -93,7 +94,7 @@ describe(FocusTrap, () => { it('renders with no focusable elements', async () => { render( - NOPE + NOPE , ); await mountActionSheetViaClick(); @@ -170,5 +171,81 @@ describe(FocusTrap, () => { await userEvent.tab(); expect(screen.getByTestId('first')).toHaveFocus(); }); + + it('manages navigation inside trap on TAB with remove last child when navigate', async () => { + const Template = (props: { childIds: string[] }) => { + return ( + + +
+ {props.childIds.map((childId) => ( + + ))} +
+
+
+ ); + }; + + const result = render(