diff --git a/src/internal/index.ts b/src/internal/index.ts index 9a277fa..c3c2d7a 100644 --- a/src/internal/index.ts +++ b/src/internal/index.ts @@ -31,6 +31,7 @@ export { getGlobalFlag } from './global-flags'; export { SingleTabStopNavigationAPI, SingleTabStopNavigationProvider, + SingleTabStopNavigationReset, useSingleTabStopNavigation, } from './single-tab-stop'; export { isFocusable, getAllFocusables, getFirstFocusable, getLastFocusable } from './focus-lock-utils/utils'; diff --git a/src/internal/single-tab-stop/__tests__/context.test.tsx b/src/internal/single-tab-stop/__tests__/context.test.tsx index 7b812c0..cf5f413 100644 --- a/src/internal/single-tab-stop/__tests__/context.test.tsx +++ b/src/internal/single-tab-stop/__tests__/context.test.tsx @@ -1,22 +1,59 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import React, { useRef } from 'react'; -import { render, act } from '@testing-library/react'; +import React, { useContext, useEffect, useRef } from 'react'; +import { render } from '@testing-library/react'; -import { SingleTabStopNavigationContext, useSingleTabStopNavigation } from '../'; +import { + SingleTabStopNavigationAPI, + SingleTabStopNavigationContext, + SingleTabStopNavigationProvider, + SingleTabStopNavigationReset, + useSingleTabStopNavigation, +} from '../'; import { renderWithSingleTabStopNavigation } from './utils'; +// Simple STSN subscriber component function Button(props: React.HTMLAttributes) { const buttonRef = useRef(null); const { tabIndex } = useSingleTabStopNavigation(buttonRef, { tabIndex: props.tabIndex }); return + + {children} + + + ); +} + +function findGroupButton(groupId: string, buttonIndex: number) { + return document.querySelector(`#${groupId}`)!.querySelectorAll('button')[buttonIndex] as HTMLElement; +} test('does not override tab index when keyboard navigation is not active', () => { renderWithSingleTabStopNavigation(