Skip to content

Commit e2227c2

Browse files
adamgenshairez
andcommitted
fix: tabs flicker
Co-authored-by: Shai Reznik <[email protected]>
1 parent ce2799f commit e2227c2

File tree

1 file changed

+17
-8
lines changed
  • packages/kit-headless/src/components/tabs

1 file changed

+17
-8
lines changed

packages/kit-headless/src/components/tabs/tabs.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,32 @@ import {
1717
/**
1818
* TABS TODOs
1919
* - Get storybook testing to work
20-
*
20+
*
2121
* - selectedIndex / default
2222
* - Orientation
2323
* - aria-label https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby
2424
* - NOTE: Radix manually handle the value/id for each tab while we calculate it behind the scenes
2525
* If we end up implementing this, we need to expose a way to set this value in the root
2626
* - keyboard interactions (arrowDown, ARrowRight, ArrowUp, ArrowLeft, Home, End, PageUp, PageDown)
27-
* Support Loop
27+
* Support Loop
2828
* - expose selectedIndex in the root
2929
* - onValueChange
3030
* POST V1:
3131
* - RTL
32-
33-
*
32+
33+
*
3434
* TAB
3535
* Disable
3636
* NOTE: radix / headlessui: expose data-state data-disable data-orientation
3737
* NOTE: Headless UI: explorer the render props
3838
* NOTE: remove tab, switch position
3939
* NOTE: scrolling support? or multiple lines? (probably not for headless but for tailwind / material )
40-
*
40+
*
4141
* PANEL
42-
*
42+
*
4343
* aria Tabs Pattern https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
4444
* a11y lint plugin https://www.npmjs.com/package/eslint-plugin-jsx-a11y
45-
*
45+
*
4646
*/
4747
export type Behavior = 'automatic' | 'manual';
4848

@@ -82,10 +82,19 @@ export const Tabs = component$((props: TabsProps) => {
8282
behavior,
8383
};
8484

85+
const tabsInitialized = useSignal(false);
86+
8587
useContextProvider(tabsContextId, contextService);
8688

89+
useVisibleTask$(() => {
90+
tabsInitialized.value = true;
91+
});
92+
8793
return (
88-
<div {...props}>
94+
<div
95+
{...props}
96+
style={'visibility:' + tabsInitialized.value ? 'visible' : 'hidden'}
97+
>
8998
<Slot />
9099
</div>
91100
);

0 commit comments

Comments
 (0)