diff --git a/.changeset/fix-sidebar-tab-ring-overflow.md b/.changeset/fix-sidebar-tab-ring-overflow.md new file mode 100644 index 000000000..ed15fc814 --- /dev/null +++ b/.changeset/fix-sidebar-tab-ring-overflow.md @@ -0,0 +1,7 @@ +--- +"@arkenv/fumadocs-ui": patch +--- + +#### Fix keyboard focus ring truncation in sidebar navigation + +The drill-in sidebar slide container now uses `overflow: clip` with an expanded clip margin instead of `overflow: hidden`, preventing keyboard focus rings from being clipped along the left and right edges. diff --git a/apps/www/app/docs/docs-chrome.css b/apps/www/app/docs/docs-chrome.css index ab86c502a..89cb8ec11 100644 --- a/apps/www/app/docs/docs-chrome.css +++ b/apps/www/app/docs/docs-chrome.css @@ -37,7 +37,20 @@ } [data-docs-sidebar-slide] { - overflow: hidden; + overflow: clip; + overflow-clip-margin: 0.5rem; +} + +@supports not (overflow-clip-margin: 0.5rem) { + [data-docs-sidebar-slide] { + margin-inline: -0.25rem; + padding-inline: 0.25rem; + } + + [data-docs-sidebar-slide] > nav.absolute { + width: auto; + inset-inline: 0.25rem; + } } /* diff --git a/packages/fumadocs-ui/css/theme.css b/packages/fumadocs-ui/css/theme.css index 9e36746e1..be6c5509b 100644 --- a/packages/fumadocs-ui/css/theme.css +++ b/packages/fumadocs-ui/css/theme.css @@ -416,7 +416,7 @@ aside .theme-toggle { color 150ms, background-color 150ms; /* Kill the UA outline (tinted by global `outline-ring/50`) — it is - rectangular and gets clipped by the drill-in `overflow-hidden` pane. */ + rectangular and gets clipped by the drill-in slide pane. */ outline: none; } @@ -459,7 +459,28 @@ aside .theme-toggle { */ #nd-sidebar [data-docs-sidebar-slide], #nd-sidebar-mobile [data-docs-sidebar-slide] { - overflow: hidden; + overflow: clip; + overflow-clip-margin: 0.5rem; +} + +/* + * WebKit / Safari fallback: WebKit supports overflow: clip but does not yet + * support overflow-clip-margin (WebKit bug 236153). Pad the slide container + * and compensate on absolutely-positioned child panels so the 4px focus ring + * paints inside the element padding box without shifting resting or drilled navs. + */ +@supports not (overflow-clip-margin: 0.5rem) { + #nd-sidebar [data-docs-sidebar-slide], + #nd-sidebar-mobile [data-docs-sidebar-slide] { + margin-inline: -0.25rem; + padding-inline: 0.25rem; + } + + #nd-sidebar [data-docs-sidebar-slide] > nav.absolute, + #nd-sidebar-mobile [data-docs-sidebar-slide] > nav.absolute { + width: auto; + inset-inline: 0.25rem; + } } #nd-sidebar [data-sidebar-mode], diff --git a/packages/fumadocs-ui/src/components/drill-in-sidebar.tsx b/packages/fumadocs-ui/src/components/drill-in-sidebar.tsx index 68092e357..6d19c8643 100644 --- a/packages/fumadocs-ui/src/components/drill-in-sidebar.tsx +++ b/packages/fumadocs-ui/src/components/drill-in-sidebar.tsx @@ -503,7 +503,7 @@ function DrillInTree() { return (