|
8 | 8 | SingleTabStopNavigationAPI, |
9 | 9 | SingleTabStopNavigationContext, |
10 | 10 | SingleTabStopNavigationProvider, |
| 11 | + SingleTabStopNavigationReset, |
11 | 12 | useSingleTabStopNavigation, |
12 | 13 | } from '../'; |
13 | 14 | import { renderWithSingleTabStopNavigation } from './utils'; |
@@ -247,4 +248,42 @@ describe('nested contexts', () => { |
247 | 248 | expect(findGroupButton('inner', 0)).toHaveAttribute('tabindex', '0'); |
248 | 249 | expect(findGroupButton('inner', 1)).toHaveAttribute('tabindex', '-1'); |
249 | 250 | }); |
| 251 | + |
| 252 | + test('ignores parent context when reset is used', () => { |
| 253 | + const { rerender } = render( |
| 254 | + <Group id="outer-most" navigationActive={true}> |
| 255 | + <SingleTabStopNavigationReset> |
| 256 | + <Group id="outer" navigationActive={true}> |
| 257 | + <Group id="inner" navigationActive={true}> |
| 258 | + {null} |
| 259 | + </Group> |
| 260 | + </Group> |
| 261 | + </SingleTabStopNavigationReset> |
| 262 | + </Group> |
| 263 | + ); |
| 264 | + expect(findGroupButton('outer-most', 0)).toHaveAttribute('tabindex', '0'); |
| 265 | + expect(findGroupButton('outer-most', 1)).toHaveAttribute('tabindex', '-1'); |
| 266 | + expect(findGroupButton('outer', 0)).toHaveAttribute('tabindex', '0'); |
| 267 | + expect(findGroupButton('outer', 1)).toHaveAttribute('tabindex', '-1'); |
| 268 | + expect(findGroupButton('inner', 0)).toHaveAttribute('tabindex', '-1'); |
| 269 | + expect(findGroupButton('inner', 1)).toHaveAttribute('tabindex', '-1'); |
| 270 | + |
| 271 | + rerender( |
| 272 | + <Group id="outer-most" navigationActive={true}> |
| 273 | + <Group id="outer" navigationActive={true}> |
| 274 | + <SingleTabStopNavigationReset> |
| 275 | + <Group id="inner" navigationActive={true}> |
| 276 | + {null} |
| 277 | + </Group> |
| 278 | + </SingleTabStopNavigationReset> |
| 279 | + </Group> |
| 280 | + </Group> |
| 281 | + ); |
| 282 | + expect(findGroupButton('outer-most', 0)).toHaveAttribute('tabindex', '0'); |
| 283 | + expect(findGroupButton('outer-most', 1)).toHaveAttribute('tabindex', '-1'); |
| 284 | + expect(findGroupButton('outer', 0)).toHaveAttribute('tabindex', '-1'); |
| 285 | + expect(findGroupButton('outer', 1)).toHaveAttribute('tabindex', '-1'); |
| 286 | + expect(findGroupButton('inner', 0)).toHaveAttribute('tabindex', '0'); |
| 287 | + expect(findGroupButton('inner', 1)).toHaveAttribute('tabindex', '-1'); |
| 288 | + }); |
250 | 289 | }); |
0 commit comments