Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] avoid focus-visible style being cut off by overflow hidden #3149

Closed
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
7 changes: 7 additions & 0 deletions .changeset/warm-glasses-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'nextra-theme-blog': patch
'nextra-theme-docs': patch
'nextra': patch
---

avoid focus-visible style being cut off by overflow-hidden
2 changes: 1 addition & 1 deletion examples/swr-site/theme.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const config: DocsThemeConfig = {
},
toc: {
extraContent: (
<img alt="placeholder cat" src="https://placekitten.com/g/300/200" />
<img alt="placeholder cat" src="https://placecats.com/300/200" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In example/swr-site, placekitten seems to be down, so I replaced it with placecats.

),
float: true
}
Expand Down
12 changes: 4 additions & 8 deletions packages/nextra-theme-docs/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function FolderImpl({ item, anchors }: FolderProps): ReactElement {
)}
/>
</ComponentToUse>
<Collapse className="ltr:_pr-0 rtl:_pl-0 _pt-1" isOpen={open}>
<Collapse className="_p-1" isOpen={open}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To resolve a situation like this

image

{Array.isArray(item.children) ? (
<Menu
className={cn(classes.border, 'ltr:_ml-3 rtl:_mr-3')}
Expand Down Expand Up @@ -400,22 +400,18 @@ export function Sidebar({
</div>
)}
<FocusedItemContext.Provider value={focused}>
<OnFocusItemContext.Provider
value={item => {
setFocused(item)
}}
>
<OnFocusItemContext.Provider value={setFocused}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that the extra inline function is not needed.

<div
className={cn(
'_overflow-y-auto _overflow-x-hidden',
'_p-4 _grow md:_h-[calc(100vh-var(--nextra-navbar-height)-var(--nextra-menu-height))]',
'_grow md:_h-[calc(100vh-var(--nextra-navbar-height)-var(--nextra-menu-height))]',
showSidebar ? 'nextra-scrollbar' : 'no-scrollbar'
)}
ref={sidebarRef}
>
{/* without asPopover check <Collapse />'s inner.clientWidth on `layout: "raw"` will be 0 and element will not have width on initial loading */}
{(!asPopover || !showSidebar) && (
<Collapse isOpen={showSidebar} horizontal>
<Collapse isOpen={showSidebar} horizontal className="_p-4">
<Menu
className="nextra-menu-desktop max-md:_hidden"
// The sidebar menu, shows only the docs directories.
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra-theme-docs/src/components/toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function TOC({ toc, filePath }: TOCProps): ReactElement {
return (
<div
className={cn(
'nextra-scrollbar _sticky _top-16 _overflow-y-auto _pr-4 _pt-6 _text-sm [hyphens:auto]',
'nextra-scrollbar _sticky _top-16 _overflow-y-auto _px-4 _pt-6 _text-sm [hyphens:auto]',
'_max-h-[calc(100vh-var(--nextra-navbar-height)-env(safe-area-inset-bottom))] ltr:_-mr-4 rtl:_-ml-4'
)}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra-theme-docs/src/mdx-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ const DEFAULT_COMPONENTS: MDXComponents = {
)
) : (
<nav
className={cn(classes.toc, '_px-4')}
className={cn(classes.toc, 'ltr:_pr-4 rtl:_pl-4')}
aria-label="table of contents"
>
{renderComponent(themeConfig.toc.component, {
Expand Down
1 change: 1 addition & 0 deletions packages/nextra/src/client/components/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function Tabs_({
disabled={disabled}
className={({ selected }) =>
cn(
index === 0 && '_ml-1', // avoid focus-visible style being cut off
'_mr-2 _rounded-t _p-2 _font-medium _leading-5 _transition-colors',
'_-mb-0.5 _select-none _border-b-2',
selected
Expand Down
Loading