-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to override style of a floating <OverflowMenu>in v9 #2876
Comments
Hi 👋 thank you for reporting - While your |
@asudoh That may actually be useful, thank you! |
@asudoh Actually this proved more troublesome than I was expecting because something in I have not yet figured out what the specific problem here is, the code is complex. Currently I am working around this by passing in a replacement |
It's the right way to go. BTW if you have some demo code that shows the layout challenge you have, we may consider taking the non- |
@asudoh Small demo of the issue I was seeing: <!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/carbon-components.css"></link>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script crossorigin src="https://unpkg.com/[email protected]/prop-types.js"></script>
<script crossorigin src="https://unpkg.com/[email protected]/dist/carbon-icons.js"></script>
<script crossorigin src="https://unpkg.com/[email protected]/index.js"></script>
<script crossorigin src="https://unpkg.com/[email protected]/umd/carbon-components-react.js"></script>
<script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/jsx">
const { OverflowMenu, OverflowMenuItem } = CarbonComponentsReact
window.addEventListener('load', () => {
ReactDOM.render(<div
data-floating-menu-container
style={{
width: '500px',
height: '500px',
backgroundColor: 'yellow',
position: 'relative',
left: '100px',
top: '100px'
}}
>
<OverflowMenu className='overflow-menu' floatingMenu>
<OverflowMenuItem itemText='Menu item 1' />
<OverflowMenuItem itemText='Menu item 2' />
</OverflowMenu>
</div>, document.querySelector('.root'))
})
</script>
</head>
<body>
<div class="root"></div>
</body>
</html> Note how the vector from the top left corner of the screen to the bottom midpoint of the menu icon is the same as the vector from the bottom midpoint of the menu icon to the tip of the arrow in the menu body. This indicates that the menu body is being positioned relative to its nearest positioned ancestor (the yellow |
Should I raise this relative positioning bug as a separate issue? |
@s100 Yes it will be great - Thanks! |
@asudoh Ah, sorry, I was referring to carbon-design-system/carbon-components-react#2389, which closes this issue (#2876) |
@asudoh Do you know when a new version of carbon-components-react@6 containing carbon-design-system/carbon-components-react#2389 will be available? |
We've marked this issue as stale because there hasn't been any activity for a couple of weeks. If there's no further activity on this issue in the next three days then we'll close it. You can keep the conversation going with just a short comment. Thanks for your contributions. |
As there's been no activity since this issue was marked as stale, we are auto-closing it. |
Summary
I would open this issue against [https://github.com/carbon-design-system/carbon-components-react] but apparently this is the new place...
In Carbon V9 (specifically,
carbon-components-react@6
) it is not possible to override the styling of an<OverflowMenu floatingMenu />
to e.g. make it wider. Specifically, the options themselves. As with nearly all Carbon components it is possible to pass aclassName
prop into the component, which can then be targeted to alter rendering. Unfortunately, when the menu options are floating, they appear at a completely different location in the DOM from where the injectedclassName
goes. So all we can do is alter the rendering of the menu icon.Justification
This would be useful for making the floating menu bigger, so that longer menu options are easier to read.
Desired UX and success metrics
Something like: when a
<OverflowMenu floatingMenu optionsClassName='x' />
is opened, the<ul>
which gets appended to the DOM should haveclass='x'
on it."Must have" functionality
That's about it!
Specific timeline issues / requests
Soon as you like, really. This is a simple request so if this isn't likely to appear in the next week I may be able to put together a PR myself.
Available extra resources
I'll try to patch this myself if I have to...
The text was updated successfully, but these errors were encountered: