1
1
import { XMarkIcon } from "@heroicons/react/24/outline" ;
2
- import { useCallback , useEffect } from "react" ;
2
+ import React , { useCallback , useEffect } from "react" ;
3
3
import { useDispatch , useSelector } from "react-redux" ;
4
4
import styled from "styled-components" ;
5
5
import { defaultBorderRadius } from ".." ;
@@ -35,6 +35,8 @@ const TabBarContainer = styled.div`
35
35
border-bottom: none;
36
36
position: relative;
37
37
margin-top: 2px;
38
+ max-height: 100px;
39
+ overflow: auto;
38
40
39
41
/* Hide scrollbar but keep functionality */
40
42
scrollbar-width: none;
@@ -125,7 +127,7 @@ const TabBarSpace = styled.div`
125
127
background-color: ${ tabBackgroundVar } ;
126
128
` ;
127
129
128
- export function TabBar ( ) {
130
+ export const TabBar = React . forwardRef < HTMLDivElement > ( ( _ , ref ) => {
129
131
const dispatch = useDispatch < AppDispatch > ( ) ;
130
132
const currentSessionId = useSelector ( ( state : RootState ) => state . session . id ) ;
131
133
const currentSessionTitle = useSelector (
@@ -141,7 +143,6 @@ export function TabBar() {
141
143
return Date . now ( ) . toString ( 36 ) + Math . random ( ) . toString ( 36 ) . substring ( 2 ) ;
142
144
} , [ ] ) ;
143
145
144
- // Handle session changes
145
146
useEffect ( ( ) => {
146
147
if ( ! currentSessionId ) return ;
147
148
@@ -224,10 +225,13 @@ export function TabBar() {
224
225
}
225
226
} ;
226
227
227
- return tabs . length === 1 ? (
228
- < > </ >
229
- ) : (
230
- < TabBarContainer >
228
+ return (
229
+ < TabBarContainer
230
+ ref = { ref }
231
+ style = { {
232
+ display : tabs . length === 1 ? "none" : "flex" ,
233
+ } }
234
+ >
231
235
{ tabs . map ( ( tab ) => (
232
236
< Tab
233
237
key = { tab . id }
@@ -253,4 +257,4 @@ export function TabBar() {
253
257
</ TabBarSpace >
254
258
</ TabBarContainer >
255
259
) ;
256
- }
260
+ } ) ;
0 commit comments