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

[core] remove non-HTML attributes in overflow menu items #3956

Merged
merged 2 commits into from
Feb 5, 2020
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/core/src/common/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const INVALID_PROPS = [
"active",
"alignText",
"containerRef",
"current",
"elementRef",
"fill",
"icon",
Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/components/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import classNames from "classnames";
import * as React from "react";
import { polyfill } from "react-lifecycles-compat";

import { AbstractPureComponent2, Boundary, Classes, IProps, Position } from "../../common";
import { AbstractPureComponent2, Boundary, Classes, IProps, Position, removeNonHTMLProps } from "../../common";
import { Menu } from "../menu/menu";
import { MenuItem } from "../menu/menuItem";
import { IOverflowListProps, OverflowList } from "../overflow-list/overflowList";
Expand Down Expand Up @@ -119,7 +119,8 @@ export class Breadcrumbs extends AbstractPureComponent2<IBreadcrumbsProps> {

private renderOverflowBreadcrumb = (props: IBreadcrumbProps, index: number) => {
const isClickable = props.href != null || props.onClick != null;
return <MenuItem disabled={!isClickable} {...props} text={props.text} key={index} />;
const htmlProps = removeNonHTMLProps(props);
return <MenuItem disabled={!isClickable} {...htmlProps} text={props.text} key={index} />;
};

private renderBreadcrumbWrapper = (props: IBreadcrumbProps, index: number) => {
Expand All @@ -133,7 +134,8 @@ export class Breadcrumbs extends AbstractPureComponent2<IBreadcrumbsProps> {
} else if (this.props.breadcrumbRenderer != null) {
return this.props.breadcrumbRenderer(props);
} else {
return <Breadcrumb {...props} current={isCurrent} />;
// allow user to override 'current' prop
return <Breadcrumb current={isCurrent} {...props} />;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ITEMS: IBreadcrumbProps[] = [
{ icon: "folder-close", text: "Janet" },
{ href: "#", icon: "folder-close", text: "Photos" },
{ href: "#", icon: "folder-close", text: "Wednesday" },
{ icon: "document", text: "image.jpg" },
{ icon: "document", text: "image.jpg", current: true },
];

export class BreadcrumbsExample extends React.PureComponent<IExampleProps, IBreadcrumbsExampleState> {
Expand Down