Add support to have the contextual menu width match the width of the target element
Bug Report
- Package version(s): (fill this out)
- Browser and OS versions: (fill this out if relevant)
I am going to try to use a workaround. This is a new search box design in OWA where when user clicks on the search box its width changes and we have to show the context menu with search suggestions. The width of the context menu should match to that of the search box width. I am going to see if I can have a place holder dummy search box, whenever user clicks on it It gets replaces with a bigger search box. I want to see if I can pass the width of the bigger search box as a ref to the suggestions context menu.
Are you willing to submit a PR to fix? ( No)
Requested priority: (Blocking, High, Normal, Low)
Products/sites affected: (if applicable)
Describe the issue:
Currently there is not way to restrict the width of the contextual menu to the width of the target / anchor element. I have an anchor element whose width changes to auto when showing the context menu.
Actual behavior:
We have to specify the width for the menu else it takes up entire widow width
Expected behavior:
Expected is to have a prop that would assign the width to contextual menu same as the anchor element
If applicable, please provide a codepen repro:
By default, the ContextualMenu takes on the width of its content. You can use the className prop to set a custom width for the ContextualMenu. Here's a CodePen where the menu's width is set to 500px. Could you use this method to make its width match the search box?
Actually I had already added support for this. I added property useTargetWidth