Skip to content

Commit

Permalink
[core] remove non-HTML attributes in overflow menu items (#3956)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Feb 5, 2020
1 parent 46b6b6b commit c2a878a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
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

1 comment on commit c2a878a

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Previews: documentation | landing | table

Please sign in to comment.