File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,13 @@ export const useSidebarFocusAndKeyboard = (sidebarId, triggerButtonSelector = '.
4545 focusSidebarTriggerBtn ( ) ;
4646 } , [ toggleSidebar , focusSidebarTriggerBtn ] ) ;
4747
48+ /**
49+ * Handles Tab key navigation when focus is on the standard sidebar close button.
50+ * Implements the logic for moving focus out of the sidebar to specific elements
51+ * on the main page in a predefined sequence, or back to the trigger button on Shift+Tab.
52+ *
53+ * @param {KeyboardEvent } event - The keyboard event object.
54+ */
4855 const handleKeyDown = useCallback ( ( event ) => {
4956 if ( event . key !== 'Tab' ) {
5057 return ;
Original file line number Diff line number Diff line change 1- // hooks/useSidebarFocusAndKeyboard.test.js (або .jsx)
21import { renderHook , act } from '@testing-library/react' ;
32import SidebarContext from '../../SidebarContext' ;
43import { useSidebarFocusAndKeyboard } from './useSidebarFocusAndKeyboard' ;
@@ -165,7 +164,6 @@ describe('useSidebarFocusAndKeyboard', () => {
165164 } ) ;
166165
167166 expect ( mockEvent . preventDefault ) . toHaveBeenCalledTimes ( 1 ) ;
168- // Перевіряємо фокус тригера
169167 act ( ( ) => { jest . runAllTimers ( ) ; } ) ;
170168 expect ( triggerButtonMock . focus ) . toHaveBeenCalledTimes ( 1 ) ;
171169 expect ( tryFocusAndPreventDefault ) . not . toHaveBeenCalled ( ) ;
You can’t perform that action at this time.
0 commit comments