MCPcopy Create free account
hub / github.com/dailydotdev/apps / onClick

Function onClick

packages/shared/src/components/tabs/TabContainer.tsx:117–137  ·  view source on GitHub ↗
(label, event)

Source from the content-addressed store, hash-verified

115 );
116
117 const onClick: TabListProps['onClick'] = (label, event) => {
118 const child = tabs.find((c) => c.props.label === label);
119 setActive(label as T);
120 const shouldChange = onActiveChange?.(label as T, event);
121
122 // evaluate !== false due to backwards compatibility with implementations that return undefined
123 if (shouldChange !== false) {
124 setTimeout(() => {
125 if (shouldFocusTabOnChange && containerRef?.current) {
126 const [firstChild] = containerRef.current.children;
127 if (firstChild instanceof HTMLElement) {
128 firstChild.focus();
129 }
130 }
131 }, 0);
132
133 if (child?.props?.url) {
134 navigateToUrl(child.props.url);
135 }
136 }
137 };
138
139 const labels = useMemo(() => tabs.map((c) => c.props.label), [tabs]);
140

Callers 2

TabListFunction · 0.70
handleClickFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected