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": "FocusZone: Add a prop to allow a FocusZone to not let focus events propagate outside of the FocusZone",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class FocusZone extends BaseComponent<IFocusZoneProps, {}> implements IFo
}

private _onFocus = (ev: React.FocusEvent<HTMLElement>): void => {
const { onActiveElementChanged } = this.props;
const { onActiveElementChanged, doNotAllowFocusEventToPropagate } = this.props;

if (this._isImmediateDescendantOfZone(ev.target as HTMLElement)) {
this._activeElement = ev.target as HTMLElement;
Expand All @@ -226,9 +226,14 @@ export class FocusZone extends BaseComponent<IFocusZoneProps, {}> implements IFo
parentElement = getParent(parentElement, ALLOW_VIRTUAL_ELEMENTS) as HTMLElement;
}
}

if (onActiveElementChanged) {
onActiveElementChanged(this._activeElement as HTMLElement, ev);
}

if (doNotAllowFocusEventToPropagate) {
ev.stopPropagation();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ export interface IFocusZoneProps extends React.HTMLAttributes<HTMLElement | Focu
* @default false
*/
checkForNoWrap?: boolean;

/**
* Whether the FocusZone should allow focus events to propagate past the FocusZone
*/
doNotAllowFocusEventToPropagate?: boolean;
}

export const enum FocusZoneTabbableElements {
Expand Down