diff --git a/docs/pages/api/breadcrumbs.md b/docs/pages/api/breadcrumbs.md
index fd9848a5234ef3..5c02c2381ceac6 100644
--- a/docs/pages/api/breadcrumbs.md
+++ b/docs/pages/api/breadcrumbs.md
@@ -27,6 +27,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| children * | node | | The breadcrumb children. |
| classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| component | elementType | 'nav' | The component used for the root node. Either a string to use a DOM element or a component. By default, it maps the variant to a good default headline component. |
+| expandText | string | 'Show path' | Override the default label for the expand button.
For localization purposes, you can use the provided [translations](/guides/localization/). |
| itemsAfterCollapse | number | 1 | If max items is exceeded, the number of items to show after the ellipsis. |
| itemsBeforeCollapse | number | 1 | If max items is exceeded, the number of items to show before the ellipsis. |
| maxItems | number | 8 | Specifies the maximum number of breadcrumbs to display. When there are more than the maximum number, only the first `itemsBeforeCollapse` and last `itemsAfterCollapse` will be shown, with an ellipsis in between. |
diff --git a/packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.js b/packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.js
index 75a5984c198fac..9d365e5653e557 100644
--- a/packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.js
+++ b/packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.js
@@ -3,19 +3,16 @@ import PropTypes from 'prop-types';
import withStyles from '../styles/withStyles';
import { emphasize } from '../styles/colorManipulator';
import MoreHorizIcon from '../internal/svg-icons/MoreHoriz';
+import ButtonBase from '../ButtonBase';
const styles = theme => ({
root: {
display: 'flex',
- },
- icon: {
- width: 24,
- height: 16,
+ marginLeft: theme.spacing(0.5),
+ marginRight: theme.spacing(0.5),
backgroundColor: theme.palette.grey[100],
color: theme.palette.grey[700],
borderRadius: 2,
- marginLeft: theme.spacing(0.5),
- marginRight: theme.spacing(0.5),
cursor: 'pointer',
'&:hover, &:focus': {
backgroundColor: theme.palette.grey[200],
@@ -25,6 +22,10 @@ const styles = theme => ({
backgroundColor: emphasize(theme.palette.grey[200], 0.12),
},
},
+ icon: {
+ width: 24,
+ height: 16,
+ },
});
/**
@@ -32,10 +33,11 @@ const styles = theme => ({
*/
function BreadcrumbCollapsed(props) {
const { classes, ...other } = props;
+
return (
-
+
-
+
);
}
diff --git a/packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.test.js b/packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.test.js
index 6a19bd311b0c5f..d90897d017872c 100644
--- a/packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.test.js
+++ b/packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.test.js
@@ -1,32 +1,42 @@
import React from 'react';
-import { assert } from 'chai';
-import { createShallow, createMount, getClasses } from '@material-ui/core/test-utils';
+import { expect } from 'chai';
+import { spy } from 'sinon';
+import { getClasses } from '@material-ui/core/test-utils';
import BreadcrumbCollapsed from './BreadcrumbCollapsed';
-import MoreHorizIcon from '../internal/svg-icons/MoreHoriz';
+import { fireEvent, createClientRender } from 'test/utils/createClientRender';
describe('', () => {
- let mount;
- let shallow;
let classes;
+ const render = createClientRender();
before(() => {
- shallow = createShallow({ dive: true });
- mount = createMount({ strict: true });
classes = getClasses();
});
- after(() => {
- mount.cleanUp();
- });
-
- it('should render an ', () => {
- const wrapper = shallow();
+ it('should render an icon', () => {
+ const { container } = render();
- assert.strictEqual(wrapper.find(MoreHorizIcon).length, 1);
- assert.strictEqual(wrapper.hasClass(classes.root), true);
+ expect(container.querySelectorAll('svg').length).to.equal(1);
+ expect(container.firstChild).to.have.class(classes.root);
});
- it('should mount', () => {
- mount();
+ describe('prop: onKeyDown', () => {
+ it(`should be called on key down - Enter`, () => {
+ const handleClick = spy();
+ const { container } = render();
+ const expand = container.firstChild;
+ expand.focus();
+ fireEvent.keyDown(expand, { key: 'Enter' });
+ expect(handleClick.callCount).to.equal(1);
+ });
+
+ it(`should be called on key up - Space`, () => {
+ const handleClick = spy();
+ const { container } = render();
+ const expand = container.firstChild;
+ expand.focus();
+ fireEvent.keyUp(expand, { key: ' ' });
+ expect(handleClick.callCount).to.equal(1);
+ });
});
});
diff --git a/packages/material-ui/src/Breadcrumbs/Breadcrumbs.js b/packages/material-ui/src/Breadcrumbs/Breadcrumbs.js
index 5e8075f5611bc1..4ff1e7c046f440 100644
--- a/packages/material-ui/src/Breadcrumbs/Breadcrumbs.js
+++ b/packages/material-ui/src/Breadcrumbs/Breadcrumbs.js
@@ -52,6 +52,7 @@ const Breadcrumbs = React.forwardRef(function Breadcrumbs(props, ref) {
classes,
className,
component: Component = 'nav',
+ expandText = 'Show path',
itemsAfterCollapse = 1,
itemsBeforeCollapse = 1,
maxItems = 8,
@@ -82,7 +83,7 @@ const Breadcrumbs = React.forwardRef(function Breadcrumbs(props, ref) {
return [
...allItems.slice(0, itemsBeforeCollapse),
- ,
+ ,
...allItems.slice(allItems.length - itemsAfterCollapse, allItems.length),
];
};
@@ -149,6 +150,12 @@ Breadcrumbs.propTypes = {
* By default, it maps the variant to a good default headline component.
*/
component: PropTypes.elementType,
+ /**
+ * Override the default label for the expand button.
+ *
+ * For localization purposes, you can use the provided [translations](/guides/localization/).
+ */
+ expandText: PropTypes.string,
/**
* If max items is exceeded, the number of items to show after the ellipsis.
*/
diff --git a/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js b/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js
index f142d2ff06564c..c2caad2659e5df 100644
--- a/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js
+++ b/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js
@@ -57,13 +57,14 @@ describe('', () => {
);
const listitems = getAllByRole('listitem', { hidden: false });
- expect(listitems).to.have.length(3);
+
+ expect(listitems).to.have.length(2);
expect(getByRole('list')).to.have.text('first//ninth');
- expect(listitems[1].querySelector('[data-mui-test="MoreHorizIcon"]')).to.be.ok;
+ expect(getByRole('button').querySelector('[data-mui-test="MoreHorizIcon"]')).to.be.ok;
});
it('should expand when `BreadcrumbCollapsed` is clicked', () => {
- const { getAllByRole } = render(
+ const { getAllByRole, getByRole } = render(
first
second
@@ -77,9 +78,9 @@ describe('', () => {
,
);
- getAllByRole('listitem', { hidden: false })[2].click();
+ getByRole('button').click();
- expect(getAllByRole('listitem', { hidden: false })).to.have.length(3);
+ expect(getAllByRole('listitem', { hidden: false })).to.have.length(9);
});
describe('warnings', () => {
diff --git a/packages/material-ui/src/locale/index.js b/packages/material-ui/src/locale/index.js
index aa4162fe6f1210..c820f717d96af3 100644
--- a/packages/material-ui/src/locale/index.js
+++ b/packages/material-ui/src/locale/index.js
@@ -291,6 +291,9 @@ export const fiFI = {
export const frFR = {
props: {
+ MuiBreadcrumbs: {
+ expandText: 'Montrer le chemin',
+ },
MuiTablePagination: {
backIconButtonText: 'Page précédente',
labelRowsPerPage: 'Lignes par page :',