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": "Button: Added public openMenu method and cleaned up open/close functions",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "mgodbolt@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState
}

public dismissMenu(): void {
this.setState({ menuProps: null });
this._dismissMenu();
}

public openMenu(): void {
this._openMenu();
}

private _onRenderContent(tag: any, buttonProps: IButtonProps): JSX.Element {
Expand Down Expand Up @@ -398,10 +402,15 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState
this.setState({ menuProps: null });
}

private _openMenu = (): void => {
if (this.props.menuProps) {
this.setState({ menuProps: this.props.menuProps });
}
}

private _onToggleMenu = (): void => {
const { menuProps } = this.props;
const currentMenuProps = this.state.menuProps;
this.setState({ menuProps: currentMenuProps ? null : menuProps });
currentMenuProps ? this._dismissMenu() : this._openMenu();
}

private _onRenderSplitButtonContent(tag: any, buttonProps: IButtonProps): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export interface IButton {
* If there is a menu associated with this button and it is visible, this will dismiss the menu
*/
dismissMenu: () => void;

/**
* If there is a menu associated with this button and it is visible, this will open the menu
*/
openMenu: () => void;
}

export interface IButtonProps extends React.AllHTMLAttributes<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement | BaseButton | Button> {
Expand Down