BaseButton onRenderMenu support isBeakVisible and other props
Bug Report
- Package version(s): 2.10.4
- Browser and OS versions: (fill this out if relevant)
Priorities and help requested (not applicable if asking question):
Are you willing to submit a PR to fix? No. It should be a easy fix.
Requested priority: (Blocking, High, Normal, Low) High
Products/sites affected: (if applicable)
Describe the issue:
in component: packages/office-ui-fabric-react/src/components/Button/BaseButton.tsx has this line this.state.menuProps && onRenderMenu(menuProps, this._onRenderMenu) which relies on menuProps from Props instead of State. This behavior can be easily achieved through onClick. onRenderMenu provides no additional benefit, i.e. anchor to the button.
In addition,
the default onRenderMenu only uses items from the Props, other things like isBeakVisible can't be set from the props as it always use {true} @autobind protected _onRenderMenu(menuProps: IContextualMenuProps): JSX.Element { return ( <ContextualMenu className={ css('ms-BaseButton-menuHost') } isBeakVisible={ true } directionalHint={ DirectionalHint.bottomLeftEdge } items={ menuProps.items } target={ this._buttonElement } labelElementId={ this._labelId } onDismiss={ this._onToggleMenu } /> ); }
Actual behavior:
this.state.menuProps && onRenderMenu(this.props.menuProps, this._onRenderMenu)
Not able to set isBeakVisible
Expected behavior:
this.state.menuProps && onRenderMenu(this.state.menuProps, this._onRenderMenu)
Able to set isBeakVisible from IButtonProps.menuProps.isBeakVisible
If applicable, please provide a codepen repro:
hmm. not sure exactly what you're saying. You can do this...
onRenderMenu={ (props, default) => <ContextualMenu isBeakVisible={ true } ... />
Can you provide more details?
we want the custom render menu function to be able to have the target and onDismiss element provided in the parameter. If I want to use custom omRenderMenu, I still have to have the contextual menu in the parent state.
The work around I found is by using this pattern: (props, defaultRenderer) => { let element = defaultRenderer(props); return (<element.type {...element.props} items={[...]} />); });
However, this is a tedious pattern I think.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Fabric React!
This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Fabric React! Why am I receiving this notification?