@oslokommune/punkt-react 20.1.6 → 20.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { fireEvent, render } from '@testing-library/react'
4
4
  import { axe, toHaveNoViolations } from 'jest-axe'
5
5
  import { vi } from 'vitest'
6
6
 
7
- import { PktTabItem, PktTabs } from './Tabs'
7
+ import { type IPktTabs, PktTabItem, PktTabs } from './Tabs'
8
8
 
9
9
  expect.extend(toHaveNoViolations)
10
10
 
@@ -269,7 +269,7 @@ describe('PktTabItem children format', () => {
269
269
  expect(firstTab).toHaveFocus()
270
270
  })
271
271
 
272
- it('stays on last tab when navigating past it with ArrowRight', () => {
272
+ it('wraps to the first tab with ArrowRight on the last tab', () => {
273
273
  const { getByText } = render(
274
274
  <PktTabs>
275
275
  <PktTabItem index={0}>First Tab</PktTabItem>
@@ -285,10 +285,10 @@ describe('PktTabItem children format', () => {
285
285
  thirdTab.focus()
286
286
  fireEvent.keyDown(thirdTab, { key: 'ArrowRight' })
287
287
 
288
- expect(thirdTab).toHaveFocus()
288
+ expect(getByText('First Tab')).toHaveFocus()
289
289
  })
290
290
 
291
- it('stays on first tab when navigating before it with ArrowLeft', () => {
291
+ it('wraps to the last tab with ArrowLeft on the first tab', () => {
292
292
  const { getByText } = render(
293
293
  <PktTabs>
294
294
  <PktTabItem index={0} active>
@@ -304,7 +304,71 @@ describe('PktTabItem children format', () => {
304
304
  firstTab.focus()
305
305
  fireEvent.keyDown(firstTab, { key: 'ArrowLeft' })
306
306
 
307
- expect(firstTab).toHaveFocus()
307
+ expect(getByText('Third Tab')).toHaveFocus()
308
+ })
309
+
310
+ it('moves focus to the first and last tab with Home and End', () => {
311
+ const { getByText } = render(
312
+ <PktTabs>
313
+ <PktTabItem index={0}>First Tab</PktTabItem>
314
+ <PktTabItem index={1} active>
315
+ Second Tab
316
+ </PktTabItem>
317
+ <PktTabItem index={2}>Third Tab</PktTabItem>
318
+ </PktTabs>,
319
+ )
320
+
321
+ getByText('Second Tab').focus()
322
+ fireEvent.keyDown(getByText('Second Tab'), { key: 'End' })
323
+ expect(getByText('Third Tab')).toHaveFocus()
324
+
325
+ fireEvent.keyDown(getByText('Third Tab'), { key: 'Home' })
326
+ expect(getByText('First Tab')).toHaveFocus()
327
+ })
328
+
329
+ it('skips disabled tabs when wrapping and with Home and End', () => {
330
+ const { getByText } = render(
331
+ <PktTabs>
332
+ <PktTabItem index={0} disabled>
333
+ Tab 1
334
+ </PktTabItem>
335
+ <PktTabItem index={1} active>
336
+ Tab 2
337
+ </PktTabItem>
338
+ <PktTabItem index={2} disabled>
339
+ Tab 3
340
+ </PktTabItem>
341
+ <PktTabItem index={3}>Tab 4</PktTabItem>
342
+ </PktTabs>,
343
+ )
344
+
345
+ getByText('Tab 4').focus()
346
+ fireEvent.keyDown(getByText('Tab 4'), { key: 'ArrowRight' })
347
+ expect(getByText('Tab 2')).toHaveFocus()
348
+
349
+ fireEvent.keyDown(getByText('Tab 2'), { key: 'Home' })
350
+ expect(getByText('Tab 2')).toHaveFocus()
351
+
352
+ fireEvent.keyDown(getByText('Tab 2'), { key: 'End' })
353
+ expect(getByText('Tab 4')).toHaveFocus()
354
+ })
355
+
356
+ it('does not select a tab when moving focus without togglePanels', () => {
357
+ const onTabSelected = vi.fn()
358
+ const { getByText } = render(
359
+ <PktTabs onTabSelected={onTabSelected}>
360
+ <PktTabItem index={0} active>
361
+ First Tab
362
+ </PktTabItem>
363
+ <PktTabItem index={1}>Second Tab</PktTabItem>
364
+ </PktTabs>,
365
+ )
366
+
367
+ getByText('First Tab').focus()
368
+ fireEvent.keyDown(getByText('First Tab'), { key: 'ArrowRight' })
369
+ fireEvent.keyDown(getByText('Second Tab'), { key: 'End' })
370
+
371
+ expect(onTabSelected).not.toHaveBeenCalled()
308
372
  })
309
373
 
310
374
  it('selects tab when Space key is pressed', () => {
@@ -586,3 +650,359 @@ describe('PktTabItem children format', () => {
586
650
  })
587
651
  })
588
652
  })
653
+
654
+ describe('togglePanels', () => {
655
+ const Panels = ({ first = {} }: { first?: Record<string, string> }) => (
656
+ <>
657
+ <div id="panel-0" {...first}>
658
+ Panel 1
659
+ </div>
660
+ <div id="panel-1">Panel 2</div>
661
+ <div id="panel-2">Panel 3</div>
662
+ </>
663
+ )
664
+
665
+ const renderWithPanels = (props: IPktTabs = { togglePanels: true }, activeIndex = 0, disabledIndex?: number) => {
666
+ const result = render(
667
+ <>
668
+ <PktTabs {...props}>
669
+ {[0, 1, 2].map((i) => (
670
+ <PktTabItem
671
+ key={i}
672
+ index={i}
673
+ controls={`panel-${i}`}
674
+ active={i === activeIndex}
675
+ disabled={i === disabledIndex}
676
+ >
677
+ {`Tab ${i + 1}`}
678
+ </PktTabItem>
679
+ ))}
680
+ </PktTabs>
681
+ <Panels />
682
+ </>,
683
+ )
684
+ const buttons = [0, 1, 2].map((i) => result.getByText(`Tab ${i + 1}`))
685
+ const panels = [0, 1, 2].map((i) => document.getElementById(`panel-${i}`) as HTMLElement)
686
+ return { ...result, buttons, panels }
687
+ }
688
+
689
+ it('shows only the panel of the active tab', () => {
690
+ const { panels } = renderWithPanels()
691
+
692
+ expect(panels.map((panel) => panel.hidden)).toEqual([false, true, true])
693
+ })
694
+
695
+ it('switches active tab and panel on click', () => {
696
+ const { buttons, panels } = renderWithPanels()
697
+
698
+ fireEvent.click(buttons[1])
699
+
700
+ expect(buttons[1]).toHaveClass('active')
701
+ expect(buttons[1]).toHaveAttribute('aria-selected', 'true')
702
+ expect(buttons[0]).toHaveAttribute('aria-selected', 'false')
703
+ expect(panels.map((panel) => panel.hidden)).toEqual([true, false, true])
704
+ })
705
+
706
+ it('switches panel with Enter', () => {
707
+ const { buttons, panels } = renderWithPanels()
708
+
709
+ fireEvent.keyDown(buttons[2], { key: 'Enter' })
710
+
711
+ expect(panels.map((panel) => panel.hidden)).toEqual([true, true, false])
712
+ })
713
+
714
+ it('still calls onTabSelected', () => {
715
+ const onTabSelected = vi.fn()
716
+ const { buttons } = renderWithPanels({ togglePanels: true, onTabSelected })
717
+
718
+ fireEvent.click(buttons[1])
719
+
720
+ expect(onTabSelected).toHaveBeenCalledWith(1)
721
+ })
722
+
723
+ it('follows active when the prop changes', () => {
724
+ const { buttons, panels, rerender } = renderWithPanels()
725
+ fireEvent.click(buttons[1])
726
+
727
+ rerender(
728
+ <>
729
+ <PktTabs togglePanels>
730
+ {[0, 1, 2].map((i) => (
731
+ <PktTabItem key={i} index={i} controls={`panel-${i}`} active={i === 2}>
732
+ {`Tab ${i + 1}`}
733
+ </PktTabItem>
734
+ ))}
735
+ </PktTabs>
736
+ <Panels />
737
+ </>,
738
+ )
739
+
740
+ expect(panels.map((panel) => panel.hidden)).toEqual([true, true, false])
741
+ })
742
+
743
+ it('keeps the selected tab when an unchanged active prop rerenders', () => {
744
+ const { buttons, panels, rerender } = renderWithPanels()
745
+ fireEvent.click(buttons[1])
746
+
747
+ rerender(
748
+ <>
749
+ <PktTabs togglePanels>
750
+ {[0, 1, 2].map((i) => (
751
+ <PktTabItem key={i} index={i} controls={`panel-${i}`} active={i === 0}>
752
+ {`Tab ${i + 1}`}
753
+ </PktTabItem>
754
+ ))}
755
+ </PktTabs>
756
+ <Panels />
757
+ </>,
758
+ )
759
+
760
+ expect(panels.map((panel) => panel.hidden)).toEqual([true, false, true])
761
+ })
762
+
763
+ it('does not select a disabled tab', () => {
764
+ const { buttons, panels } = renderWithPanels({ togglePanels: true }, 0, 1)
765
+
766
+ fireEvent.keyDown(buttons[1], { key: 'Enter' })
767
+
768
+ expect(panels.map((panel) => panel.hidden)).toEqual([false, true, true])
769
+ })
770
+
771
+ it('works with items wrapped in other elements', () => {
772
+ const { getByText } = render(
773
+ <>
774
+ <PktTabs togglePanels>
775
+ {[0, 1, 2].map((i) => (
776
+ <div key={i}>
777
+ <PktTabItem index={i} controls={`panel-${i}`} active={i === 0}>
778
+ {`Tab ${i + 1}`}
779
+ </PktTabItem>
780
+ </div>
781
+ ))}
782
+ </PktTabs>
783
+ <Panels />
784
+ </>,
785
+ )
786
+
787
+ fireEvent.click(getByText('Tab 3'))
788
+
789
+ expect([0, 1, 2].map((i) => document.getElementById(`panel-${i}`)?.hidden)).toEqual([true, true, false])
790
+ })
791
+
792
+ it('works with the tabs prop', () => {
793
+ const { getByText } = render(
794
+ <>
795
+ <PktTabs
796
+ togglePanels
797
+ tabs={[0, 1, 2].map((i) => ({ text: `Tab ${i + 1}`, controls: `panel-${i}`, active: i === 0 }))}
798
+ />
799
+ <Panels />
800
+ </>,
801
+ )
802
+
803
+ fireEvent.click(getByText('Tab 2'))
804
+
805
+ expect([0, 1, 2].map((i) => document.getElementById(`panel-${i}`)?.hidden)).toEqual([true, false, true])
806
+ })
807
+
808
+ it('links tabs and panels', () => {
809
+ const { buttons, panels } = renderWithPanels()
810
+
811
+ expect(buttons[0]).toHaveAttribute('id', 'panel-0-tab')
812
+ expect(panels[0]).toHaveAttribute('role', 'tabpanel')
813
+ expect(panels[0]).toHaveAttribute('aria-labelledby', 'panel-0-tab')
814
+ expect(panels[0]).toHaveAttribute('tabindex', '0')
815
+ expect(panels[1]).toHaveAttribute('aria-labelledby', 'panel-1-tab')
816
+ })
817
+
818
+ it('keeps role, label and tabindex already set on the panel', () => {
819
+ render(
820
+ <>
821
+ <PktTabs togglePanels>
822
+ <PktTabItem index={0} controls="panel-0" active>
823
+ Tab 1
824
+ </PktTabItem>
825
+ </PktTabs>
826
+ <Panels first={{ role: 'region', 'aria-label': 'Egen', tabIndex: '-1' }} />
827
+ </>,
828
+ )
829
+ const panel = document.getElementById('panel-0')
830
+
831
+ expect(panel).toHaveAttribute('role', 'region')
832
+ expect(panel).toHaveAttribute('tabindex', '-1')
833
+ expect(panel).not.toHaveAttribute('aria-labelledby')
834
+ })
835
+
836
+ it('selects the tab that arrow keys, Home and End move to', () => {
837
+ const onTabSelected = vi.fn()
838
+ const { buttons, panels } = renderWithPanels({ togglePanels: true, onTabSelected })
839
+
840
+ buttons[0].focus()
841
+ fireEvent.keyDown(buttons[0], { key: 'ArrowRight' })
842
+ expect(buttons[1]).toHaveAttribute('aria-selected', 'true')
843
+ expect(panels.map((panel) => panel.hidden)).toEqual([true, false, true])
844
+
845
+ fireEvent.keyDown(buttons[1], { key: 'End' })
846
+ expect(buttons[2]).toHaveFocus()
847
+ expect(panels.map((panel) => panel.hidden)).toEqual([true, true, false])
848
+
849
+ fireEvent.keyDown(buttons[2], { key: 'End' })
850
+ expect(onTabSelected.mock.calls).toEqual([[1], [2]])
851
+ })
852
+
853
+ it('toggles panels without tab semantics when arrow navigation is disabled', () => {
854
+ const { buttons, panels } = renderWithPanels({ togglePanels: true, disableArrowNav: true })
855
+
856
+ fireEvent.click(buttons[1])
857
+
858
+ expect(panels.map((panel) => panel.hidden)).toEqual([true, false, true])
859
+ expect(panels[1]).not.toHaveAttribute('role')
860
+ expect(panels[1]).not.toHaveAttribute('aria-labelledby')
861
+ expect(panels[1]).not.toHaveAttribute('tabindex')
862
+ })
863
+
864
+ it('leaves panels and markup alone without togglePanels', () => {
865
+ const { buttons, panels } = renderWithPanels({})
866
+
867
+ fireEvent.click(buttons[1])
868
+
869
+ expect(buttons[0]).toHaveClass('active')
870
+ expect(buttons[1]).not.toHaveClass('active')
871
+ expect(panels.map((panel) => panel.hidden)).toEqual([false, false, false])
872
+ expect(panels[0]).not.toHaveAttribute('role')
873
+ expect(buttons[0]).not.toHaveAttribute('id')
874
+ })
875
+
876
+ it('should not have any accessibility violations', async () => {
877
+ const { container } = renderWithPanels()
878
+
879
+ expect(await axe(container)).toHaveNoViolations()
880
+ })
881
+ })
882
+
883
+ describe('labels and current item', () => {
884
+ it('labels the tab list with aria-label', async () => {
885
+ const { container } = render(
886
+ <PktTabs ariaLabel="Faner">
887
+ <PktTabItem index={0} active>
888
+ Tab 1
889
+ </PktTabItem>
890
+ </PktTabs>,
891
+ )
892
+
893
+ expect(container.querySelector('.pkt-tabs__list')).toHaveAttribute('aria-label', 'Faner')
894
+ expect(await axe(container)).toHaveNoViolations()
895
+ })
896
+
897
+ it('labels the tab list with aria-labelledby', () => {
898
+ const { container } = render(
899
+ <PktTabs ariaLabelledBy="overskrift">
900
+ <PktTabItem index={0} active>
901
+ Tab 1
902
+ </PktTabItem>
903
+ </PktTabs>,
904
+ )
905
+
906
+ expect(container.querySelector('.pkt-tabs__list')).toHaveAttribute('aria-labelledby', 'overskrift')
907
+ })
908
+
909
+ it('marks the active link as the current page in navigation mode', () => {
910
+ const { getByText } = render(
911
+ <PktTabs disableArrowNav>
912
+ <PktTabItem index={0} href="/a" active>
913
+ A
914
+ </PktTabItem>
915
+ <PktTabItem index={1} href="/b">
916
+ B
917
+ </PktTabItem>
918
+ </PktTabs>,
919
+ )
920
+
921
+ expect(getByText('A')).toHaveAttribute('aria-current', 'page')
922
+ expect(getByText('B')).not.toHaveAttribute('aria-current')
923
+ })
924
+
925
+ it('marks the active button as current in navigation mode', () => {
926
+ const { getByText } = render(
927
+ <PktTabs disableArrowNav>
928
+ <PktTabItem index={0} active>
929
+ A
930
+ </PktTabItem>
931
+ </PktTabs>,
932
+ )
933
+
934
+ expect(getByText('A')).toHaveAttribute('aria-current', 'true')
935
+ })
936
+
937
+ it('uses aria-selected, not aria-current, with tab semantics', () => {
938
+ const { getByText } = render(
939
+ <PktTabs>
940
+ <PktTabItem index={0} active>
941
+ A
942
+ </PktTabItem>
943
+ </PktTabs>,
944
+ )
945
+
946
+ expect(getByText('A')).not.toHaveAttribute('aria-current')
947
+ })
948
+
949
+ it('gives the tag the blue skin by default', () => {
950
+ const { getByText } = render(
951
+ <PktTabs>
952
+ <PktTabItem index={0} tag="Ny">
953
+ A
954
+ </PktTabItem>
955
+ </PktTabs>,
956
+ )
957
+
958
+ expect(getByText('Ny').closest('.pkt-tag')).toHaveClass('pkt-tag--blue')
959
+ })
960
+ })
961
+
962
+ describe('focus without an active tab', () => {
963
+ const renderTabs = (activeIndex?: number) => (
964
+ <PktTabs>
965
+ <PktTabItem index={0} disabled>
966
+ Tab 1
967
+ </PktTabItem>
968
+ <PktTabItem index={1} active={activeIndex === 1}>
969
+ Tab 2
970
+ </PktTabItem>
971
+ <PktTabItem index={2} active={activeIndex === 2}>
972
+ Tab 3
973
+ </PktTabItem>
974
+ </PktTabs>
975
+ )
976
+
977
+ it('makes the first enabled tab reachable with Tab', () => {
978
+ const { getByText } = render(renderTabs())
979
+
980
+ expect(getByText('Tab 1')).toHaveAttribute('tabindex', '-1')
981
+ expect(getByText('Tab 2')).not.toHaveAttribute('tabindex')
982
+ expect(getByText('Tab 3')).toHaveAttribute('tabindex', '-1')
983
+ })
984
+
985
+ it('drops the fallback once a tab is active', () => {
986
+ const { getByText, rerender } = render(renderTabs())
987
+
988
+ rerender(renderTabs(2))
989
+
990
+ expect(getByText('Tab 2')).toHaveAttribute('tabindex', '-1')
991
+ expect(getByText('Tab 3')).not.toHaveAttribute('tabindex')
992
+ })
993
+
994
+ it('works with items wrapped in other elements', () => {
995
+ const { getByText } = render(
996
+ <PktTabs>
997
+ {[0, 1].map((i) => (
998
+ <div key={i}>
999
+ <PktTabItem index={i}>{`Tab ${i + 1}`}</PktTabItem>
1000
+ </div>
1001
+ ))}
1002
+ </PktTabs>,
1003
+ )
1004
+
1005
+ expect(getByText('Tab 1')).not.toHaveAttribute('tabindex')
1006
+ expect(getByText('Tab 2')).toHaveAttribute('tabindex', '-1')
1007
+ })
1008
+ })
@@ -8,20 +8,30 @@ import {
8
8
  KeyboardEvent,
9
9
  ReactNode,
10
10
  Ref,
11
+ useCallback,
11
12
  useContext,
12
13
  useEffect,
13
14
  useRef,
15
+ useState,
14
16
  } from 'react'
15
17
 
16
18
  import type { TTagSkin } from 'shared-types'
19
+ import { tabIndexForKey } from 'shared-utils/tabs/keyboard'
17
20
 
18
21
  import { PktIcon } from '../icon/Icon'
19
22
  import { PktTabItem } from './TabItem'
20
23
  import { withStableKeys } from '../../utils/stableKeys'
21
24
 
25
+ type TTabState = { active: boolean; disabled: boolean }
26
+
22
27
  // Context for passing tab navigation logic to children
23
28
  interface ITabsContext {
24
29
  arrowNav: boolean
30
+ togglePanels: boolean
31
+ selectedIndex: number | null
32
+ setSelectedIndex: (index: number) => void
33
+ fallbackFocusIndex: number | null
34
+ reportTab: (index: number, state: TTabState | null) => void
25
35
  registerTabRef: (index: number, el: HTMLAnchorElement | HTMLButtonElement | null, disabled?: boolean) => void
26
36
  handleKeyPress: (index: number, event: KeyboardEvent<HTMLAnchorElement | HTMLButtonElement>) => void
27
37
  selectTab: (index: number) => void
@@ -56,6 +66,9 @@ export interface IPktTabs {
56
66
  disableArrowNav?: boolean
57
67
  separatorIconName?: string
58
68
  separatorIconPath?: string
69
+ togglePanels?: boolean
70
+ ariaLabel?: string
71
+ ariaLabelledBy?: string
59
72
  tabs?: IPktTab[]
60
73
  onTabSelected?: (index: number) => void
61
74
  children?: ReactNode
@@ -68,6 +81,9 @@ export const PktTabs = forwardRef(
68
81
  disableArrowNav = false,
69
82
  separatorIconName,
70
83
  separatorIconPath,
84
+ togglePanels = false,
85
+ ariaLabel,
86
+ ariaLabelledBy,
71
87
  tabs,
72
88
  onTabSelected,
73
89
  children,
@@ -76,6 +92,28 @@ export const PktTabs = forwardRef(
76
92
  ): JSX.Element => {
77
93
  const tabElementsRef = useRef<Array<HTMLAnchorElement | HTMLButtonElement | null>>([])
78
94
  const disabledMapRef = useRef<Record<number, boolean>>({})
95
+ const [selectedIndex, setSelectedIndex] = useState<number | null>(null)
96
+ const [tabStates, setTabStates] = useState<Record<number, TTabState> | null>(null)
97
+
98
+ const reportTab = useCallback((index: number, state: TTabState | null) => {
99
+ setTabStates((previous) => {
100
+ const current = previous?.[index]
101
+ const unchanged = state ? current?.active === state.active && current?.disabled === state.disabled : !current
102
+ if (unchanged) return previous
103
+ const next = { ...previous }
104
+ if (state) next[index] = state
105
+ else delete next[index]
106
+ return next
107
+ })
108
+ }, [])
109
+
110
+ const fallbackFocusIndex =
111
+ tabStates && !Object.values(tabStates).some((tab) => tab.active)
112
+ ? (Object.keys(tabStates)
113
+ .map(Number)
114
+ .filter((index) => !tabStates[index].disabled)
115
+ .sort((a, b) => a - b)[0] ?? null)
116
+ : null
79
117
 
80
118
  const useArrowNav = arrowNav && !disableArrowNav
81
119
 
@@ -106,32 +144,18 @@ export const PktTabs = forwardRef(
106
144
  tab.action(index)
107
145
  }
108
146
  if (onTabSelected) onTabSelected(index)
109
- }
110
-
111
- const findEnabledIndex = (startIndex: number, direction: -1 | 1): number | null => {
112
- let current = startIndex + direction
113
-
114
- while (current >= 0 && current < tabCount) {
115
- if (!isTabDisabled(current)) return current
116
- current += direction
117
- }
118
-
119
- return null
147
+ if (togglePanels) setSelectedIndex(index)
120
148
  }
121
149
 
122
150
  const handleKeyPress = (index: number, event: KeyboardEvent<HTMLAnchorElement | HTMLButtonElement>) => {
123
151
  if (!useArrowNav) return
124
152
 
125
- if (event.key === 'ArrowLeft') {
126
- event.preventDefault()
127
- const previousEnabled = findEnabledIndex(index, -1)
128
- if (previousEnabled !== null) tabElementsRef.current[previousEnabled]?.focus()
129
- }
130
-
131
- if (event.key === 'ArrowRight') {
153
+ const target = tabIndexForKey(event.key, index, tabCount, isTabDisabled)
154
+ if (target !== null) {
132
155
  event.preventDefault()
133
- const nextEnabled = findEnabledIndex(index, 1)
134
- if (nextEnabled !== null) tabElementsRef.current[nextEnabled]?.focus()
156
+ tabElementsRef.current[target]?.focus()
157
+ if (togglePanels && target !== index) selectTab(target)
158
+ return
135
159
  }
136
160
 
137
161
  if (event.key === 'Enter' || event.key === ' ' || event.key === 'Spacebar' || event.key === 'ArrowDown') {
@@ -186,9 +210,26 @@ export const PktTabs = forwardRef(
186
210
  const renderedTabs = withSeparators((hasChildren ? childItems : tabItems || []) as ReactNode[])
187
211
 
188
212
  return (
189
- <TabsContext.Provider value={{ arrowNav: useArrowNav, registerTabRef, handleKeyPress, selectTab }}>
213
+ <TabsContext.Provider
214
+ value={{
215
+ arrowNav: useArrowNav,
216
+ togglePanels,
217
+ selectedIndex,
218
+ setSelectedIndex,
219
+ fallbackFocusIndex,
220
+ reportTab,
221
+ registerTabRef,
222
+ handleKeyPress,
223
+ selectTab,
224
+ }}
225
+ >
190
226
  <div className={tabsClasses} ref={ref}>
191
- <div className="pkt-tabs__list" role={useArrowNav ? 'tablist' : 'navigation'}>
227
+ <div
228
+ className="pkt-tabs__list"
229
+ role={useArrowNav ? 'tablist' : 'navigation'}
230
+ aria-label={ariaLabel || undefined}
231
+ aria-labelledby={ariaLabelledBy || undefined}
232
+ >
192
233
  {renderedTabs}
193
234
  </div>
194
235
  </div>