Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Add focus method to Breadcrumb",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "v-hudole@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from 'react';
import {
BaseComponent,
css,
getRTL
getRTL,
createRef
} from '../../Utilities';
import { FocusZone, FocusZoneDirection } from '../../FocusZone';
import { Link } from '../../Link';
Expand Down Expand Up @@ -31,10 +32,21 @@ export class Breadcrumb extends BaseComponent<IBreadcrumbProps, any> {
maxDisplayedItems: 999
};

protected focusZone = createRef<FocusZone>();

constructor(props: IBreadcrumbProps) {
super(props);
}

/**
* Sets focus to the first breadcrumb link.
*/
public focus(): void {
if (this.focusZone.value) {
this.focusZone.value.focus();
}
}

public render() {
const { onReduceData = this._onReduceData, maxDisplayedItems, items } = this.props;
const breadCrumbData: IBreadCrumbData = {
Expand Down Expand Up @@ -93,7 +105,7 @@ export class Breadcrumb extends BaseComponent<IBreadcrumbProps, any> {
role='navigation'
aria-label={ ariaLabel }
>
<FocusZone direction={ FocusZoneDirection.horizontal } >
<FocusZone componentRef={ this.focusZone } direction={ FocusZoneDirection.horizontal } >
<ol className={ css('ms-Breadcrumb-list', styles.list) }>
{ renderedOverflowItems && renderedOverflowItems.length !== 0 && (
<li className={ css('ms-Breadcrumb-overflow', styles.overflow) } key={ OVERFLOW_KEY }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { IIconProps } from '../Icon';
import { IRenderFunction, IComponentAs } from '../../Utilities';

export interface IBreadcrumb {

/**
* Sets focus to the first breadcrumb link.
*/
focus(): void;
}

export interface IBreadcrumbProps extends React.Props<Breadcrumb> {
Expand Down