Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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": "BaseButton: Allow Alt + Down on menu buttons to open the menu",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState

private _openMenu = (shouldFocusOnContainer?: boolean): void => {
if (this.props.menuProps) {
const menuProps = {...this.props.menuProps, shouldFocusOnContainer: shouldFocusOnContainer };
const menuProps = { ...this.props.menuProps, shouldFocusOnContainer: shouldFocusOnContainer };
if (this.props.persistMenu) {
menuProps.hidden = false;
}
Expand Down Expand Up @@ -639,6 +639,9 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState
ev.preventDefault();
ev.stopPropagation();
}

// Note: When enter is pressed, we will let the event continue to propagate
// to trigger the onClick event on the button
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment seems a little out of place since there is no code under it (I get what you are trying to do here but it feels weird)... consider moving it to a better place

}

private _onTouchStart: () => void = () => {
Expand Down Expand Up @@ -679,13 +682,10 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState
private _isValidMenuOpenKey(ev: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement | HTMLButtonElement>): boolean {
if (this.props.menuTriggerKeyCode) {
return ev.which === this.props.menuTriggerKeyCode;
} else {
if (this._isSplitButton) {
return ev.which === KeyCodes.down && (ev.altKey || ev.metaKey);
} else {
return ev.which === KeyCodes.enter;
}
} else if (this.props.menuProps) {
return ev.which === KeyCodes.down && (ev.altKey || ev.metaKey);
}
return false;
}

private _onMenuClick = (ev: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>) => {
Expand Down