Skip to content

Commit

Permalink
use span as default element for Hidden component
Browse files Browse the repository at this point in the history
This improves the HTML DOM tree if this happens to be used in let's say
a `p` tag where `div` elements are not allowed. The `Hidden` element is
hidden so it doesn't really matter what the underlying element is.

Fixes: #3319
  • Loading branch information
RobinMalfait committed Jul 4, 2024
1 parent d8f44e0 commit 03bc0f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@headlessui-react/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(
)

if (!selected && (theirProps.unmount ?? true) && !(theirProps.static ?? false)) {
return <Hidden as="span" aria-hidden="true" {...ourProps} />
return <Hidden aria-hidden="true" {...ourProps} />
}

return render({
Expand Down
2 changes: 1 addition & 1 deletion packages/@headlessui-react/src/internal/hidden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ElementType, Ref } from 'react'
import type { Props } from '../types'
import { forwardRefWithAs, render, type HasDisplayName, type RefProp } from '../utils/render'

let DEFAULT_VISUALLY_HIDDEN_TAG = 'div' as const
let DEFAULT_VISUALLY_HIDDEN_TAG = 'span' as const

export enum HiddenFeatures {
// The default, no features.
Expand Down

0 comments on commit 03bc0f9

Please sign in to comment.