Fix modals being unregistered inside command menu (#9155)
Fix modals being unregistered inside command menu
This commit is contained in:
@ -82,7 +82,11 @@ describe('useCommandMenu', () => {
|
||||
const onClickMock = jest.fn();
|
||||
|
||||
act(() => {
|
||||
result.current.commandMenu.onItemClick(onClickMock, '/test');
|
||||
result.current.commandMenu.onItemClick({
|
||||
shouldCloseCommandMenuOnClick: true,
|
||||
onClick: onClickMock,
|
||||
to: '/test',
|
||||
});
|
||||
});
|
||||
|
||||
expect(result.current.isCommandMenuOpened).toBe(true);
|
||||
|
||||
@ -216,8 +216,21 @@ export const useCommandMenu = () => {
|
||||
);
|
||||
|
||||
const onItemClick = useCallback(
|
||||
(onClick?: () => void, to?: string) => {
|
||||
toggleCommandMenu();
|
||||
({
|
||||
shouldCloseCommandMenuOnClick,
|
||||
onClick,
|
||||
to,
|
||||
}: {
|
||||
shouldCloseCommandMenuOnClick?: boolean;
|
||||
onClick?: () => void;
|
||||
to?: string;
|
||||
}) => {
|
||||
if (
|
||||
isDefined(shouldCloseCommandMenuOnClick) &&
|
||||
shouldCloseCommandMenuOnClick
|
||||
) {
|
||||
toggleCommandMenu();
|
||||
}
|
||||
|
||||
if (isDefined(onClick)) {
|
||||
onClick();
|
||||
|
||||
Reference in New Issue
Block a user