diff --git a/packages/components/src/tabs/tab.tsx b/packages/components/src/tabs/tab.tsx index 75b3df1c1ba01e..e8a245259ea248 100644 --- a/packages/components/src/tabs/tab.tsx +++ b/packages/components/src/tabs/tab.tsx @@ -18,7 +18,7 @@ export const Tab = forwardRef< HTMLButtonElement, TabProps >( function Tab( ) { const context = useContext( TabsContext ); if ( ! context ) { - warning( '`Tabs.TabList` must be wrapped in a `Tabs` component.' ); + warning( '`Tabs.Tab` must be wrapped in a `Tabs` component.' ); return null; } const { store, instanceId } = context; diff --git a/packages/components/src/tabs/tablist.tsx b/packages/components/src/tabs/tablist.tsx index 02255fefd20827..373fef8a4de106 100644 --- a/packages/components/src/tabs/tablist.tsx +++ b/packages/components/src/tabs/tablist.tsx @@ -8,18 +8,18 @@ import * as Ariakit from '@ariakit/react'; * WordPress dependencies */ import warning from '@wordpress/warning'; -import { forwardRef } from '@wordpress/element'; +import { forwardRef, useContext } from '@wordpress/element'; /** * Internal dependencies */ import type { TabListProps } from './types'; -import { useTabsContext } from './context'; +import { TabsContext } from './context'; import { TabListWrapper } from './styles'; export const TabList = forwardRef< HTMLDivElement, TabListProps >( function TabList( { children, className, style }, ref ) { - const context = useTabsContext(); + const context = useContext( TabsContext ); if ( ! context ) { warning( '`Tabs.TabList` must be wrapped in a `Tabs` component.' ); return null; diff --git a/packages/edit-post/src/components/sidebar/settings-header/index.js b/packages/edit-post/src/components/sidebar/settings-header/index.js index f4f7a34db0bc3d..6cc0011e5f5f9b 100644 --- a/packages/edit-post/src/components/sidebar/settings-header/index.js +++ b/packages/edit-post/src/components/sidebar/settings-header/index.js @@ -1,7 +1,10 @@ /** * WordPress dependencies */ -import { Button } from '@wordpress/components'; +import { + Button, + privateApis as componentsPrivateApis, +} from '@wordpress/components'; import { __, _x, sprintf } from '@wordpress/i18n'; import { useDispatch, useSelect } from '@wordpress/data'; import { store as editorStore } from '@wordpress/editor'; @@ -10,6 +13,9 @@ import { store as editorStore } from '@wordpress/editor'; * Internal dependencies */ import { store as editPostStore } from '../../../store'; +import { unlock } from '../../../lock-unlock'; + +const { Tabs } = unlock( componentsPrivateApis ); const SettingsHeader = ( { sidebarName } ) => { const { openGeneralSidebar } = useDispatch( editPostStore ); @@ -45,48 +51,51 @@ const SettingsHeader = ( { sidebarName } ) => { ? [ __( 'Template (selected)' ), 'is-active' ] : [ __( 'Template' ), '' ]; - /* Use a list so screen readers will announce how many tabs there are. */ return ( -