Closed
Description
Before #53502,
<C.DropdownMenu icon="move" label="Select a direction">
{({ onClose }) => (
<div>
<button onClick={onClose}>Click me</button>
</div>
)}
</C.DropdownMenu>;
Gave a contextual type to onClose
. Now it does not. Here are some snippets of the wordpress/components code:
In dropdown-menu/index.d.ts:
declare namespace DropdownMenu {
// ....
interface PropsWithChildren extends BaseProps {
/**
* A function render prop which should return an element or elements
* valid for use in a `DropdownMenu`: `MenuItem`, `MenuItemsChoice`, or
* `MenuGroup`.
*/
children(props: Dropdown.RenderProps): JSX.Element;
controls?: never | undefined;
}
// .....
type Props = PropsWithChildren | PropsWithControls;
}
declare const DropdownMenu: ComponentType<DropdownMenu.Props>;
export default DropdownMenu;
and in dropdown/index.d.ts
declare namespace Dropdown {
// ....
interface RenderProps {
/**
* Whether the dropdown menu is opened or not.
*/
isOpen: boolean;
/**
* A function switching the dropdown menu's state from open to closed
* and vice versa.
*/
onToggle(): void;
/**
* A function that closes the menu if invoked.
*/
onClose(): void;
}
}