File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
packages/kit-headless/src/components/tabs Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
11
11
} from '@builder.io/qwik' ;
12
12
import { tabsContextId } from './tabs-context-id' ;
13
13
import { KeyCode } from '../../utils/key-code.type' ;
14
- import { isServer } from '@builder.io/qwik/build' ;
14
+ import { isBrowser , isServer } from '@builder.io/qwik/build' ;
15
15
16
16
export interface TabProps {
17
17
onClick ?: PropFunction < ( ) => void > ;
@@ -26,12 +26,18 @@ export const Tab = component$((props: TabProps) => {
26
26
const serverAssignedIndexSig = useSignal < number | undefined > ( undefined ) ;
27
27
const uniqueId = useId ( ) ;
28
28
29
- useTask$ ( ( ) => {
29
+ useTask$ ( ( { cleanup } ) => {
30
30
if ( isServer ) {
31
31
serverAssignedIndexSig . value =
32
32
contextService . lastAssignedTabIndexSig . value ;
33
33
contextService . lastAssignedTabIndexSig . value ++ ;
34
34
}
35
+ if ( isBrowser ) {
36
+ contextService . onTabsChanged$ ( ) ;
37
+ }
38
+ cleanup ( ( ) => {
39
+ contextService . onTabsChanged$ ( ) ;
40
+ } ) ;
35
41
} ) ;
36
42
37
43
useTask$ ( ( { track } ) => {
Original file line number Diff line number Diff line change 8
8
useSignal ,
9
9
} from '@builder.io/qwik' ;
10
10
import { tabsContextId } from './tabs-context-id' ;
11
- import { isServer } from '@builder.io/qwik/build' ;
11
+ import { isBrowser , isServer } from '@builder.io/qwik/build' ;
12
12
13
13
export interface TabPanelProps {
14
14
class ?: string ;
@@ -25,12 +25,18 @@ export const TabPanel = component$(({ ...props }: TabPanelProps) => {
25
25
( ) => contextService . tabPanelsMap [ panelUID ] ?. tabId
26
26
) ;
27
27
28
- useTask$ ( ( ) => {
28
+ useTask$ ( ( { cleanup } ) => {
29
29
if ( isServer ) {
30
30
serverAssignedIndexSig . value =
31
31
contextService . lastAssignedPanelIndexSig . value ;
32
32
contextService . lastAssignedPanelIndexSig . value ++ ;
33
33
}
34
+ if ( isBrowser ) {
35
+ contextService . onTabsChanged$ ( ) ;
36
+ }
37
+ cleanup ( ( ) => {
38
+ contextService . onTabsChanged$ ( ) ;
39
+ } ) ;
34
40
} ) ;
35
41
36
42
const isSelectedSignal = useComputed$ ( ( ) => {
You can’t perform that action at this time.
0 commit comments