Skip to content

Commit 136075f

Browse files
sserrataclaude
andcommitted
fix(theme): scope inner CodeTabs defaultValue to current language's samples
The inner x-codeSamples CodeTabs was passing the global selectedSample state as defaultValue for every outer language tab. When selectedSample held an id from a different language (e.g. "Python-KeyPair Auth" while rendering the C# tab), Docusaurus's <Tabs> validation threw: "<Tabs> has a defaultValue 'Python-KeyPair Auth' but none of its children has the corresponding value. Available values are: C#-0." Guard the defaultValue so each language's inner tabs only adopt selectedSample when the id belongs to that language's samples; otherwise fall back to the language's first sample. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 507f7d7 commit 136075f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ function CodeSnippets({
296296
}}
297297
includeSample={true}
298298
currentLanguage={lang}
299-
defaultValue={selectedSample}
299+
defaultValue={
300+
selectedSample && lang.samples.includes(selectedSample)
301+
? selectedSample
302+
: lang.samples[0]
303+
}
300304
languageSet={mergedLangs}
301305
lazy
302306
>

0 commit comments

Comments
 (0)