MCPcopy Create free account
hub / github.com/adobe/react-spectrum / TabList

Function TabList

packages/dev/s2-docs/src/Tabs.tsx:94–117  ·  view source on GitHub ↗
(props: TabListProps<T>)

Source from the content-addressed store, hash-verified

92});
93
94export function TabList<T extends object>(props: TabListProps<T>) {
95 let state = useContext(TabListStateContext);
96 let [selectedTab, setSelectedTab] = useState<HTMLElement | undefined>(undefined);
97 let tablistRef = useRef<HTMLDivElement>(null);
98
99 useLayoutEffect(() => {
100 if (tablistRef?.current) {
101 let tab: HTMLElement | null = tablistRef.current.querySelector(
102 '[role=tab][data-selected=true]'
103 );
104
105 if (tab != null) {
106 setSelectedTab(tab);
107 }
108 }
109 }, [tablistRef, state?.selectedItem?.key]);
110
111 return (
112 <div className={style({position: 'relative'})}>
113 <TabLine selectedTab={selectedTab} />
114 <RACTabList {...props} ref={tablistRef} className={tablist} />
115 </div>
116 );
117}
118
119interface TabLineProps {
120 selectedTab: HTMLElement | undefined;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected