ContextMenu with split button and the width not automatic does not handle text wider than the dropdown well
Environment Information
- Package version(s): 6.189.2
- Browser and OS versions: (fill this out if relevant)
Please provide a reproduction of the bug in a codepen:
Repro by going to https://fabricweb.z5.web.core.windows.net/oufr/6.189.2/#/examples/contextmenu and on the ContextualMenu with checkable menu items and toggleable split button change the width of the ms-ContextualMenu to 223px (mimicking constrained with the useTargetWidth option) and you will see the last menu item is not correctly centered and the split button is not correct. If you delete an the ms-Icon-placeHolder from one of the menu items with the split (which will be how it is if you don't have icons) and make the text a fair bit longer you will see how it it runs off both sizes and pushes the split arrow off the side.
Actual behavior:
Text is cut off on both sides and the arrow on the right is pushed off the screen
Expected behavior:
Text is correctly pruned with the ellipsis as happens without the split menu.
Priorities and help requested:
Are you willing to submit a PR to fix? (Yes, No) Maybe, I haven't looked into the code closely on this issue yet.
Requested priority: (Blocking, High, Normal, Low) Normal. We are GA with the feature using this on June 13th, but it only affects long strings. Not sure how to workaround it yet, but it doesn't make the feature unusable, but it is a bad experience for the user if the text is too long.
Products/sites affected: (if applicable) www.microsoftpartnerconnect.com
Hey @jgage176 thanks for opening this issue! This definitely looks like a bug. Here's a screenshot of what I'm seeing for reference.

I'll discuss this behavior with the team and get back to you!
I added this to my css and it fixes up the issue quite nicely:
[class*="splitContainer"] [class*="splitPrimary"] { width: calc(100% - 28px); }
The 28px is the min-width of the split menu arrow so it goes quite nice with it. I tried a lot of other css fixes, but this one seems to work flawlessly at every size for a very small change.
Maybe in office-ui-fabric-react/packages/office-ui-fabric-react/src/components/ContextualMenu/ContextualMenu.classNames.ts: around line 134:
splitPrimary: [
styles.root,
{
width: `calc(100% - ${CONTEXTUAL_SPLIT_MENU_WIDTH})`
},
And then on line 152
splitMenu: [
styles.root,
{
flexBasis: '0',
padding: '0 8px',
minWidth: CONTEXTUAL_SPLIT_MENU_WIDTH
},

Side note is that below ~180px in width the split menu starts disappear - feels like some sort of min-width issue, but I don't see it right off:

Probably needs a separate bug.
On the last note I realized that this is the base minWidth of components and is probably okay. They really shouldn't go smaller than that and if they do it is probably okay to start cutting it off. At some point it has to say: this is all the smaller I get, otherwise you would just have … for all the menu items.
:tada:This issue was addressed in #9406, which has now been successfully released as [email protected].:tada:
Handy links: