diff --git a/docs/src/modules/components/BackToTop.tsx b/docs/src/modules/components/BackToTop.tsx index 350a47294afb74..b2c5de3573695c 100644 --- a/docs/src/modules/components/BackToTop.tsx +++ b/docs/src/modules/components/BackToTop.tsx @@ -35,14 +35,14 @@ export default function BackToTop() { return ( - - + + - - + + ); } diff --git a/docs/src/modules/components/SearchButton.tsx b/docs/src/modules/components/SearchButton.tsx index c19b5930bf6a75..44b57b75c57c09 100644 --- a/docs/src/modules/components/SearchButton.tsx +++ b/docs/src/modules/components/SearchButton.tsx @@ -96,17 +96,18 @@ function useShortcut() { export default function SearchButton({ onClick, onRef, ...props }: SearchButtonProps) { const t = useTranslate(); const shortcut = useShortcut(); + const labelId = React.useId(); return ( - {t('searchButton')} + {t('searchButton')} {shortcut && } ); diff --git a/docs/src/modules/components/ThemeViewer.tsx b/docs/src/modules/components/ThemeViewer.tsx index f0a6e1645e6e16..bd23f524af7772 100644 --- a/docs/src/modules/components/ThemeViewer.tsx +++ b/docs/src/modules/components/ThemeViewer.tsx @@ -187,8 +187,6 @@ export function useItemIdsLazy(object: Record) { return allItemIds; } -const keyPrefix = '$ROOT'; - export default function ThemeViewer({ data, expandPaths = [], @@ -197,12 +195,13 @@ export default function ThemeViewer({ data: Record; expandPaths: Array | null; }) { + const keyPrefix = React.useId(); const defaultExpanded = React.useMemo( () => Array.isArray(expandPaths) ? expandPaths.map((expandPath) => `${keyPrefix}.${expandPath}`) : [], - [expandPaths], + [expandPaths, keyPrefix], ); // for default* to take effect we need to remount const key = React.useMemo(() => defaultExpanded.join(''), [defaultExpanded]); diff --git a/packages/mui-docs/src/ApiPage/sections/ToggleDisplayOption.tsx b/packages/mui-docs/src/ApiPage/sections/ToggleDisplayOption.tsx index dacba447796e4b..5f2e3c17c093e0 100644 --- a/packages/mui-docs/src/ApiPage/sections/ToggleDisplayOption.tsx +++ b/packages/mui-docs/src/ApiPage/sections/ToggleDisplayOption.tsx @@ -84,6 +84,9 @@ interface ToggleDisplayOptionProps { export function ToggleDisplayOption(props: ToggleDisplayOptionProps) { const { displayOption, setDisplayOption, sectionType } = props; + const id = React.useId(); + const buttonId = `${id}-view-switching-button`; + const menuId = `${id}-view-options-menu`; const [anchorEl, setAnchorEl] = React.useState(null); const [open, setOpen] = React.useState(false); @@ -108,8 +111,8 @@ export function ToggleDisplayOption(props: ToggleDisplayOptionProps) { size="small" variant="outlined" color="secondary" - id="view-switching-button" - aria-controls={open ? 'view-switching-button' : undefined} + id={buttonId} + aria-controls={open ? menuId : undefined} aria-haspopup="true" aria-expanded={open ? 'true' : undefined} onClick={handleMenuClick} @@ -122,7 +125,7 @@ export function ToggleDisplayOption(props: ToggleDisplayOptionProps) { {displayOption}