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

fix(Breadcrumb): items dropdownProps loss #43151

Merged
merged 3 commits into from
Jun 22, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions components/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { BreadcrumbItemProps } from './BreadcrumbItem';
import BreadcrumbItem, { InternalBreadcrumbItem } from './BreadcrumbItem';
import BreadcrumbSeparator from './BreadcrumbSeparator';

import type { DropdownProps } from '../dropdown';
import useStyle from './style';
import useItemRender from './useItemRender';
import useItems from './useItems';
Expand All @@ -30,6 +31,7 @@ export interface BreadcrumbItemType {
/** @deprecated Please use `menu` instead */
overlay?: React.ReactNode;
className?: string;
dropdownProps?: DropdownProps;
onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;

/** @deprecated Please use `menu` instead */
Expand Down Expand Up @@ -123,6 +125,7 @@ const Breadcrumb = (props: BreadcrumbProps) => {
onClick,
className: itemClassName,
separator: itemSeparator,
dropdownProps,
} = item;
const mergedPath = getPath(params, path);

Expand All @@ -145,10 +148,6 @@ const Breadcrumb = (props: BreadcrumbProps) => {
itemProps.overlay = overlay as any;
}

if (itemClassName) {
itemProps.className = itemClassName;
}

let { href } = item;
if (paths.length && mergedPath !== undefined) {
href = `#/${paths.join('/')}`;
Expand All @@ -162,6 +161,8 @@ const Breadcrumb = (props: BreadcrumbProps) => {
data: true,
aria: true,
})}
className={itemClassName}
dropdownProps={dropdownProps}
href={href}
separator={isLastItem ? '' : separator}
onClick={onClick}
Expand Down
22 changes: 22 additions & 0 deletions components/breadcrumb/__tests__/Breadcrumb.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,26 @@ describe('Breadcrumb', () => {
it('Breadcrumb.Item menu type', () => {
expect(<Breadcrumb.Item menu={{ selectable: true }} />).toBeTruthy();
});

it('dropdownProps in items should be worked', () => {
render(
<Breadcrumb
items={[
{
title: 'test',
menu: {
items: [
{
key: '1',
label: 'label',
},
],
},
dropdownProps: { open: true },
},
]}
/>,
);
expect(document.querySelector('.ant-dropdown')).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion components/breadcrumb/demo/overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Breadcrumb } from 'antd';
import React from 'react';

const menuItems = [
{
Expand Down