1
1
import React , { forwardRef , useEffect , useState } from 'react' ;
2
+
2
3
import debounce from 'lodash/debounce' ;
3
4
4
5
import type { ITab , TabsProps } from '../../typings/hyper' ;
@@ -15,20 +16,20 @@ const Tabs = forwardRef<HTMLElement, TabsProps>((props, ref) => {
15
16
16
17
const [ shouldFocusCounter , setShouldFocusCounter ] = useState ( {
17
18
index : 0 ,
18
- when : undefined as ( Date | undefined )
19
+ when : undefined as Date | undefined
19
20
} ) ;
20
21
21
- const scrollToActiveTab = debounce ( ( tabs : ITab [ ] ) => {
22
- const activeTab = tabs . findIndex ( t => t . isActive ) ;
22
+ const scrollToActiveTab = debounce ( ( currTabs : ITab [ ] ) => {
23
+ const activeTab = currTabs . findIndex ( ( t ) => t . isActive ) ;
23
24
setShouldFocusCounter ( {
24
25
index : activeTab ,
25
26
when : new Date ( )
26
- } )
27
+ } ) ;
27
28
} , 100 ) ;
28
29
29
30
useEffect ( ( ) => {
30
- scrollToActiveTab ( tabs )
31
- } , [ tabs , tabs . length ] )
31
+ scrollToActiveTab ( tabs ) ;
32
+ } , [ tabs , tabs . length ] ) ;
32
33
33
34
const hide = ! isMac && tabs . length === 1 ;
34
35
@@ -50,7 +51,7 @@ const Tabs = forwardRef<HTMLElement, TabsProps>((props, ref) => {
50
51
hasActivity,
51
52
onSelect : onChange . bind ( null , uid ) ,
52
53
onClose : onClose . bind ( null , uid ) ,
53
- lastFocused : undefined as ( Date | undefined ) ,
54
+ lastFocused : undefined as Date | undefined
54
55
} ) ;
55
56
if ( shouldFocusCounter . index === i ) {
56
57
tabProps . lastFocused = shouldFocusCounter . when ;
@@ -110,7 +111,8 @@ const Tabs = forwardRef<HTMLElement, TabsProps>((props, ref) => {
110
111
overflow-x: auto;
111
112
}
112
113
113
- .tabs_list::-webkit-scrollbar, .tabs_list::-webkit-scrollbar-button {
114
+ .tabs_list::-webkit-scrollbar,
115
+ .tabs_list::-webkit-scrollbar-button {
114
116
display: none;
115
117
}
116
118
0 commit comments