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

Toolbar/ToolbarDropdownMenu Typescript Conversion #54321

Merged
merged 5 commits into from
Sep 11, 2023
Merged
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

### Internal

- `Toolbar/ToolbarDropdownMenu `: Convert to TypeScript ([#54321](https://github.com/WordPress/gutenberg/pull/54321)).
- `Composite`: Convert to TypeScript ([#54028](https://github.com/WordPress/gutenberg/pull/54028)).
- `BorderControl`: Refactor unit tests to use `userEvent` ([#54155](https://github.com/WordPress/gutenberg/pull/54155))
- `FocusableIframe`: Convert to TypeScript ([#53979](https://github.com/WordPress/gutenberg/pull/53979)).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
// @ts-nocheck

/**
* WordPress dependencies
*/
import { forwardRef, useContext } from '@wordpress/element';

/**
* External dependencies
*/
import type { ForwardedRef } from 'react';

/**
* Internal dependencies
*/
import ToolbarItem from '../toolbar-item';
import ToolbarContext from '../toolbar-context';
import DropdownMenu from '../../dropdown-menu';
import type { DropdownMenuProps } from '../../dropdown-menu/types';

function ToolbarDropdownMenu( props, ref ) {
function ToolbarDropdownMenu(
props: DropdownMenuProps,
ref: ForwardedRef< any >
) {
const accessibleToolbarState = useContext( ToolbarContext );

if ( ! accessibleToolbarState ) {
return <DropdownMenu { ...props } />;
}

// ToobarItem will pass all props to the render prop child, which will pass
// ToolbarItem will pass all props to the render prop child, which will pass
// all props to the toggle of DropdownMenu. This means that ToolbarDropdownMenu
// has the same API as DropdownMenu.
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type WordPressComponentProps<
> = P &
// The `children` prop is being explicitly omitted since it is otherwise implicitly added
// by `ComponentPropsWithRef`. The context is that components should require the `children`
// prop explicitely when needed (see https://github.com/WordPress/gutenberg/pull/31817).
// prop explicitly when needed (see https://github.com/WordPress/gutenberg/pull/31817).
Omit< React.ComponentPropsWithoutRef< T >, 'as' | keyof P | 'children' > &
( IsPolymorphic extends true
? {
Expand Down
Loading