File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
www/packages/docs-ui/src/components/CodeTabs Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ export const CodeTabs = ({
175175 group,
176176 } )
177177
178- const tabRefs : ( HTMLButtonElement | null ) [ ] = useMemo ( ( ) => [ ] , [ ] )
178+ const tabRefs = useRef < ( HTMLButtonElement | null ) [ ] > ( [ ] )
179179 const codeTabSelectorRef = useRef < HTMLSpanElement | null > ( null )
180180 const codeTabsWrapperRef = useRef < HTMLDivElement | null > ( null )
181181
@@ -221,8 +221,8 @@ export const CodeTabs = ({
221221 )
222222
223223 useEffect ( ( ) => {
224- if ( codeTabSelectorRef ?. current && tabRefs . length ) {
225- const selectedTabElm = tabRefs . find (
224+ if ( codeTabSelectorRef ?. current && tabRefs . current . length ) {
225+ const selectedTabElm = tabRefs . current . find (
226226 ( tab ) => tab ?. getAttribute ( "aria-selected" ) === "true"
227227 )
228228 if ( selectedTabElm ) {
@@ -250,6 +250,9 @@ export const CodeTabs = ({
250250 }
251251 } , [ selectedTab ] )
252252
253+ // Reset tabRefs array before each render
254+ tabRefs . current = [ ]
255+
253256 return (
254257 < div
255258 className = { clsx (
@@ -299,7 +302,7 @@ export const CodeTabs = ({
299302 { ...( typeof child . props === "object" ? child . props : { } ) }
300303 changeSelectedTab = { changeSelectedTab }
301304 pushRef = { ( tabButton : HTMLButtonElement | null ) =>
302- tabRefs . push ( tabButton )
305+ tabRefs . current . push ( tabButton )
303306 }
304307 blockStyle = { blockStyle }
305308 isSelected = {
You can’t perform that action at this time.
0 commit comments