Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages-internal/core-docs/src/Demo/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ export function Demo(props: DemoProps) {
console.error('Code content not copied', error);
}
};
const willRenderTabList = demoData.relativeModules && openDemoSource && !editorCode.isPreview;

return (
<Root>
Expand Down Expand Up @@ -667,7 +668,7 @@ export function Demo(props: DemoProps) {
)}
</DemoToolbarRoot>
<Tabs.Root value={activeTab} onValueChange={handleTabChange}>
{demoData.relativeModules && openDemoSource && !editorCode.isPreview ? (
{willRenderTabList ? (
<CodeTabList ownerState={ownerState}>
{tabs.map((tab, index) => (
<CodeTab
Expand All @@ -685,7 +686,12 @@ export function Demo(props: DemoProps) {
{/* A limitation from https://github.com/nihgwu/react-runner,
we can't inject the `window` of the iframe so we need a disableLiveEdit option. */}
{tabs.map((tab, index) => (
<Tabs.Panel value={index} key={index}>
<Tabs.Panel
role={willRenderTabList ? 'tabpanel' : undefined}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like taking too much control over from the base ui component.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the most correct way would be not use the Tabs at all if there are no tabs, but this is fine 😅

value={index}
key={index}
tabIndex={-1}
>
{demoOptions.disableLiveEdit || index > 0 ? (
<DemoCodeViewer
key={index}
Expand Down
2 changes: 1 addition & 1 deletion packages-internal/core-docs/src/Demo/DemoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function DemoEditor(props: DemoEditorProps) {
{...other}
>
<div className="MuiCode-root" {...handlers}>
<div className="scrollContainer">
<div className="scrollContainer" tabIndex={-1}>
<NoSsr>
<CodeCopyButton {...copyButtonProps} code={value} />
</NoSsr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export function HighlightedCodeWithTabs(
))}
</CodeTabList>
{tabs.map(({ tab, language, code }) => (
<CodeTabPanel ownerState={ownerState} key={tab} value={tab}>
<CodeTabPanel ownerState={ownerState} key={tab} value={tab} tabIndex={-1}>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed here since the tablist is always rendered.

<HighlightedCode
language={language || 'bash'}
code={typeof code === 'function' ? code(tab) : code}
Expand Down
Loading